Skip to content

Commit

Permalink
Revert "Add pytest workflow"
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojustin authored Apr 27, 2024
1 parent 2b61b97 commit c0c5303
Show file tree
Hide file tree
Showing 7 changed files with 1,647 additions and 24,857 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/pytester.yml

This file was deleted.

22 changes: 2 additions & 20 deletions backend/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Fetches from met museum api to create game and return data to frontend
"""
# pylint: disable=global-statement

import random
from datetime import datetime
from flask import Flask, jsonify, request
Expand All @@ -12,21 +12,10 @@

app = Flask(__name__)
client = MongoClient('mongodb://localhost:27017/', 27017)
app.config['DB_NAME'] = 'metguessr_users'
db = client[app.config['DB_NAME']] # Database name
db = client['metguessr_users'] # Database name
users = db.users # users collection
scores = db.scores # scores collection

def get_db():
"""
Sets up the correct database
"""
global users
global scores
newdb = client[app.config['DB_NAME']]
users = newdb.users
scores = newdb.scores

def fetch_object_ids():
"""
Fetches met museum api for all object ids.
Expand All @@ -46,7 +35,6 @@ def login():
"""
Route that handles logging in.
"""
get_db()
if request.method == 'POST':
data = request.get_json() # get input
username = data.get('username')
Expand All @@ -63,7 +51,6 @@ def register():
"""
Route that handles registering a new user.
"""
get_db()
data = request.get_json() # get input
username = data.get('username')
password = data.get('password')
Expand All @@ -81,7 +68,6 @@ def get_user(username):
"""
Route that retrieves a user by a username, added in the parameter
"""
get_db()
user = users.find_one({'name': username}, {'_id': 0, 'password': 0}) # exclude sensitive info
if user:
return jsonify(user), 200
Expand All @@ -92,7 +78,6 @@ def get_user_scores(username):
"""
Fetches the high score and the average score for the specified user.
"""
get_db()
# get highest score
high_score_data = scores.find_one(
{'username': username},
Expand Down Expand Up @@ -160,7 +145,6 @@ def add_score():
"""
Route that adds a score to the leaderboard
"""
get_db()
username = request.json.get('username')
score = request.json.get('score')

Expand All @@ -173,7 +157,6 @@ def get_scores():
"""
Route that retrieves all scores sorted by score in descending order
"""
get_db()
all_scores = scores.find().sort('score', -1)
return jsonify([{'username': x['username'],
'score': x['score'],
Expand All @@ -185,7 +168,6 @@ def get_user_games():
"""
Route that retrieves games for a user
"""
get_db()
username = request.args.get('username')
user_games = scores.find({'username': username}).sort('timestamp', -1)
return jsonify([{'username': x['username'],
Expand Down
7 changes: 0 additions & 7 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,19 @@ click==8.1.7
colorama==0.4.6
dill==0.3.8
dnspython==2.6.1
exceptiongroup==1.2.1
Flask==3.0.3
idna==3.7
importlib_metadata==7.1.0
iniconfig==2.0.0
isort==5.13.2
itsdangerous==2.2.0
Jinja2==3.1.3
MarkupSafe==2.1.5
mccabe==0.7.0
packaging==24.0
platformdirs==4.2.0
pluggy==1.5.0
pylint==3.1.0
pymongo==4.7.0
pytest==8.1.2
requests==2.31.0
tomli==2.0.1
tomlkit==0.12.4
typing_extensions==4.11.0
urllib3==2.2.1
Werkzeug==3.0.2
zipp==3.18.1
130 changes: 0 additions & 130 deletions backend/tests/test_app.py

This file was deleted.

Loading

0 comments on commit c0c5303

Please sign in to comment.