diff --git a/Backend/PetFuc.py b/Backend/PetFuc.py deleted file mode 100644 index bb0475a..0000000 --- a/Backend/PetFuc.py +++ /dev/null @@ -1,9 +0,0 @@ -from flask import Flask, json, request, jsonify - - -def Get_Random_Pet(): - randomint = "9" # APi generates random interger that represents a PET ID - # Api accesses database and return information in data base - #Retrun information such as profile picture on the pet accosiated with the random ID - return jsonify({"id": randomint,"name":"sam","sex":"male","Age":"8", "location":"Connecticwut", "Breed": "Pug"}) # Return dog information - diff --git a/Backend/UserFuc.py b/Backend/UserFuc.py deleted file mode 100644 index 30dae00..0000000 --- a/Backend/UserFuc.py +++ /dev/null @@ -1,28 +0,0 @@ -from flask import Flask, request, json, jsonify - -UserFaviorteDataBase = [] # pretend this is a database - -UserAccInfo = {"Name":"eric","Password":"2020", "Location":"connecticut","Occupation":"Student"} # example user information - -# add user faviorte pet to database -def Add_User_Faviorte(jsondata): - UserFaviorteDataBase.append(jsondata) - - # accesses database and append post json in database - return UserFaviorteDataBase # return new user database - - -# Remove user faviorte pet to database -def Remove_User_Faviorte(jsondata): - UserFaviorteDataBase.remove(jsondata) - - # accesses database and append post json in database - return UserFaviorteDataBase # return new user database - - -# Change a Users account location -def Replace_User_Location(NewLocation): - NewLocation = NewLocation.get('Location') - - UserAccInfo["Location"] = NewLocation # Set location accosiated with user to new location - return UserAccInfo # retrun user account info diff --git a/Backend/main.py b/Backend/main.py deleted file mode 100644 index bb429fa..0000000 --- a/Backend/main.py +++ /dev/null @@ -1,40 +0,0 @@ -from flask import Flask, json, request, jsonify -import random -from PetFuc import Get_Random_Pet -from UserFuc import Add_User_Faviorte, Remove_User_Faviorte, Replace_User_Location - - - -app = Flask(__name__) - -#Get Random Pet information - For homepage -@app.route("/Get_Random_pet", methods=["GET"]) -def get_random_pet(): - return Get_Random_Pet(), 200 # Return dog information - -# Faviortes route. add user faviorte pet to database -@app.route("/Add_User_Faviorte", methods=["POST"]) -def add_user_faviorte(): - json_data = request.get_json() - - # Api accesses database and append post json in database - #Retrun database with succses code - return jsonify(Add_User_Faviorte(json_data)), 200 - -# Un Faviote Route. remove user faviorte pet from there database -@app.route("/Remove_User_Faviorte", methods=["DELETE"]) -def remove_user_faviorte(): - json_data = request.get_json() - - # Api accesses database and append post json in database - #Retrun database with succses code - return jsonify(Remove_User_Faviorte(json_data)), 200 # return new user database - -# Change a Users account location -@app.route("/Change_User_Location", methods=["PUT"]) -def replace_user_information(): - NewLocation = request.get_json() # Get new location from post request - return jsonify(Replace_User_Location(NewLocation)) # retrun user account info - -if __name__ == "__main__": - app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/Backend/test_main.py b/Backend/test_main.py deleted file mode 100644 index 57becdf..0000000 --- a/Backend/test_main.py +++ /dev/null @@ -1,132 +0,0 @@ -import requests -from flask import Flask, json, request, jsonify - -def test_Get_Random_pet(): - """ - Test for http://localhost:5000/Get_Random_pet - """ - - url = "http://localhost:5000" - - response = requests.get(url + "/Get_Random_pet") - - expected_response = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticwut", - "Breed": "Pug" - } - - assert response.json() == expected_response - -# ----------------------------------------------------------------------------- - -def test_Add_User_Faviorte(): - """ - Test for http://localhost:5000/Add_User_Faviorte - """ - - url = "http://localhost:5000" - - FaviortePet1 = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticut", - "Breed": "Pug" - } - - - response = requests.post((url + "/Add_User_Faviorte"), json=(FaviortePet1)) - - assert response.json() == [{'Age': '8', 'Breed': 'Pug', 'id': '9', 'location': 'Connecticut', 'name': 'sam', 'sex': 'male'}] - - FaviortePet2 = { - "id": "90", - "name": "ben", - "sex": "male", - "Age": "2", - "location": "New York", - "Breed": "Husky" - } - - response = requests.post((url + "/Add_User_Faviorte"), json=(FaviortePet2)) - - assert response.json() == [{'Age': '8', 'Breed': 'Pug', 'id': '9', 'location': 'Connecticut', 'name': 'sam', 'sex': 'male'}, {'Age': '2', 'Breed': 'Husky', 'id': '90' -, 'location': 'New York', 'name': 'ben', 'sex': 'male'}] - -# ---------------------------------------------------------------------------------- - -def test_Remove_User_Faviorte(): - """ - Test for http://localhost:5000/Remove_User_Faviorte - """ - - url = "http://localhost:5000" - - FaviortePet1 = { - "id": "9", - "name": "sam", - "sex": "male", - "Age": "8", - "location": "Connecticut", - "Breed": "Pug" - } - - - response = requests.delete((url + "/Remove_User_Faviorte"), json=(FaviortePet1)) - - assert response.json() == [{'Age': '2', 'Breed': 'Husky', 'id': '90', 'location': 'New York', 'name': 'ben', 'sex': 'male'}] - - FaviortePet2 = { - "id": "90", - "name": "ben", - "sex": "male", - "Age": "2", - "location": "New York", - "Breed": "Husky" - } - - response = requests.delete((url + "/Remove_User_Faviorte"), json=(FaviortePet2)) - - assert response.json() == [] -# ---------------------------------------------------------------------------------- - - - -def test_Change_User_Location(): - """ - Test for http://localhost:5000/Change_User_Location - """ - - url = "http://localhost:5000" - - response = requests.put((url + "/Change_User_Location"), json={"Location":"New York"}) - - assert response.json() == {"Location": "New York","Name": "eric","Occupation": "Student","Password": "2020"} - - - response = requests.put((url + "/Change_User_Location"), json={"Location":"Chicago"}) - - assert response.json() == {"Location": "Chicago","Name": "eric","Occupation": "Student","Password": "2020"} - - response = requests.put((url + "/Change_User_Location"), json={"Location":"Massachusetts"}) - - assert response.json() == {"Location": "Massachusetts","Name": "eric","Occupation": "Student","Password": "2020"} - - - - - - - - - -test_Get_Random_pet() -test_Add_User_Faviorte() -test_Remove_User_Faviorte() -test_Change_User_Location() -print("Test check Complete: Passed")