Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
made requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vucis committed Mar 20, 2024
1 parent 02913d7 commit 548e126
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions backend/project/endpoints/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def post(self):
uid = request.json.get('uid')
is_teacher = request.json.get('is_teacher')
is_admin = request.json.get('is_admin')
url = f"{API_URL}/users"

if is_teacher is None or is_admin is None or uid is None:
return {
Expand All @@ -64,7 +65,7 @@ def post(self):
"uid": "User ID (string)",
"is_teacher": "Teacher status (boolean)",
"is_admin": "Admin status (boolean)"
},"url": f"{API_URL}/users"
},"url": url
}, 400
try:
user = db.session.get(userModel, uid)
Expand All @@ -76,13 +77,13 @@ def post(self):
db.session.add(new_user)
db.session.commit()
return jsonify({"message": "User created successfully!",
"data": user, "url": f"{API_URL}/users/{user.uid}", "status_code": 201})
"data": user, "url": f"{url}/{user.uid}", "status_code": 201})

except SQLAlchemyError:
# every exception should result in a rollback
db.session.rollback()
return {"message": "An error occurred while creating the user",
"url": f"{API_URL}/users"}, 500
"url": url}, 500


class User(Resource):
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/endpoints/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ def client(app):
def valid_teacher_entry(session):
"""A valid teacher for testing that's already in the db"""
teacher = User(uid="Bart", is_teacher=True, is_admin=False)
session.add(teacher)
try:
session.add(teacher)
session.commit()
except SQLAlchemyError:
session.rollback()
Expand Down
5 changes: 1 addition & 4 deletions backend/tests/endpoints/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def test_remove_project(client, valid_project_entry):
assert response.status_code == 404

def test_patch_project(client, valid_project_entry):
"""
Test functionality of the PATCH method for projects
Test functionality of the PATCH method for projects
"""
"""Test functionality of the PATCH method for projects"""

project_id = valid_project_entry.project_id

Expand Down

0 comments on commit 548e126

Please sign in to comment.