Skip to content

Commit

Permalink
added test for put
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerwoud committed Feb 25, 2024
1 parent aa0269d commit 792ddd9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
3 changes: 0 additions & 3 deletions backend/project/endpoints/projects/project_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def put(self, **kwargs):
id: int = kwargs['project_id']

args = parser.parse_args()
print(args)

values = {key: value for key, value in args.items() if value is not None}

project = Projects.query.filter_by(project_id=id).first() # .update(values=values)

Expand Down
22 changes: 20 additions & 2 deletions backend/tests/endpoints/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def test_getting_all_projects(client):

def test_post_remove_project(client):
"""Test adding a user to the datab and fetching it"""
response = client.get("/projects/1")
assert response.status_code == 404

data = {
"title": "YourProject for testing purposes 123451",
Expand Down Expand Up @@ -45,3 +43,23 @@ def test_post_remove_project(client):
response = client.delete(f"/projects/{to_rem['project_id']}")

assert response.status_code == 204
response = client.delete(f"/projects/{to_rem['project_id']}")
assert response.status_code == 404

def test_update_project(client):
response = client.get("/projects")
assert response.status_code == 200
json_data = response.json[0]

new_archieved = not json_data["archieved"]
new_title = "just patched title"

response = client.put(f"/projects/{json_data['project_id']}", json={"title": new_title, "archieved": new_archieved})

assert response.status_code == 200

response = client.get(f"/projects/{json_data['project_id']}")
data = response.json
assert response.status_code == 200
assert data['title'] == new_title
assert data['archieved'] == new_archieved

0 comments on commit 792ddd9

Please sign in to comment.