From b641f049328410f1c1f6334ff5f55a7d2c0a60a6 Mon Sep 17 00:00:00 2001 From: IshayuR Date: Wed, 30 Oct 2024 22:40:14 -0400 Subject: [PATCH] good ol' pylint fixes --- Backend/main.py | 3 ++- Backend/pet_func.py | 1 + Backend/test_main.py | 20 +++++++++++++------- Backend/user_func.py | 3 +-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Backend/main.py b/Backend/main.py index 641896e..270ed02 100644 --- a/Backend/main.py +++ b/Backend/main.py @@ -1,5 +1,6 @@ # Module main.py -# This module is the main entry point for the pet adoption web application. It defines routes and their functions. +# This module is the main entry point for the pet adoption web application. +# It defines routes and their functions for managing pets and user information. from flask import Flask, request, jsonify from pet_func import get_random_pet from user_func import add_user_favorite, remove_user_favorite, replace_user_location diff --git a/Backend/pet_func.py b/Backend/pet_func.py index 891fcf7..71477a3 100644 --- a/Backend/pet_func.py +++ b/Backend/pet_func.py @@ -1,5 +1,6 @@ # Module pet_func.py # This module handles pet-related functionalities, providing details about random pets. +# It uses the Flask framework to return pet information in a JSON format. from flask import jsonify def get_random_pet(): diff --git a/Backend/test_main.py b/Backend/test_main.py index 57d1d38..3a7bf11 100644 --- a/Backend/test_main.py +++ b/Backend/test_main.py @@ -1,31 +1,37 @@ # Module test_main.py -# This module contains unit tests for the pet adoption web application, testing the functionality of various endpoints. +# This module contains unit tests for the pet adoption web application, testing the functionality +# of various endpoints. It uses the requests library to simulate HTTP requests. import requests def test_get_random_pet(): """Test for http://localhost:5000/get_random_pet.""" url = "http://localhost:5000" response = requests.get(f"{url}/get_random_pet", timeout=10) - expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + expected_response = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} assert response.json() == expected_response def test_add_user_favorite(): """Test for http://localhost:5000/add_user_favorite.""" url = "http://localhost:5000" - favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} response = requests.post(f"{url}/add_user_favorite", json=favorite_pet1, timeout=10) assert response.json() == [favorite_pet1] - favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", + "location": "New York", "Breed": "Husky"} response = requests.post(f"{url}/add_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [favorite_pet1, favorite_pet2] def test_remove_user_favorite(): """Test for http://localhost:5000/remove_user_favorite.""" url = "http://localhost:5000" - favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", "location": "Connecticut", "Breed": "Pug"} + favorite_pet1 = {"id": "9", "name": "Sam", "sex": "Male", "Age": "8", + "location": "Connecticut", "Breed": "Pug"} response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet1, timeout=10) - assert response.json() == [] # Assuming the database is modified accordingly - favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", "location": "New York", "Breed": "Husky"} + assert response.json() == [] + favorite_pet2 = {"id": "90", "name": "Ben", "sex": "Male", "Age": "2", + "location": "New York", "Breed": "Husky"} response = requests.delete(f"{url}/remove_user_favorite", json=favorite_pet2, timeout=10) assert response.json() == [] diff --git a/Backend/user_func.py b/Backend/user_func.py index 41db0a0..f02b029 100644 --- a/Backend/user_func.py +++ b/Backend/user_func.py @@ -1,6 +1,5 @@ # Module user_func.py -# This module handles user-related functionalities, including managing favorites and user information. -from flask import jsonify +# This module handles user-related functionalities such as managing favorites and updating user information. user_favorite_database = [] # Simulate a database for user favorites user_acc_info = {"Name": "Eric", "Password": "2020", "Location": "Connecticut", "Occupation": "Student"}