Skip to content

Commit

Permalink
good ol' pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IshayuR committed Oct 31, 2024
1 parent 0c2e4ce commit b641f04
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Backend/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions Backend/pet_func.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
20 changes: 13 additions & 7 deletions Backend/test_main.py
Original file line number Diff line number Diff line change
@@ -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() == []

Expand Down
3 changes: 1 addition & 2 deletions Backend/user_func.py
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down

0 comments on commit b641f04

Please sign in to comment.