Skip to content

Commit

Permalink
one test for each API call
Browse files Browse the repository at this point in the history
  • Loading branch information
julien4215 committed Feb 28, 2024
1 parent bb9b555 commit 66c7ec6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def test_create_picture():
headers={"Authorization": f"Bearer {token_BDE}"},
)
assert response.status_code == 201


def test_create_picture_for_non_existing_recommendation():
with open("assets/images/default_recommendation.png", "rb") as image:
response = client.post(
"/recommendation/recommendations/false_id/picture",
Expand Down Expand Up @@ -83,6 +86,9 @@ def test_create_recommendation():
headers={"Authorization": f"Bearer {token_BDE}"},
)
assert response.status_code == 201


def test_create_recommendation_with_no_body():
response = client.post(
"/recommendation/recommendations",
json={},
Expand All @@ -98,12 +104,18 @@ def test_edit_recommendation():
headers={"Authorization": f"Bearer {token_BDE}"},
)
assert response.status_code == 204


def test_edit_recommendation_with_no_body():
response = client.patch(
f"/recommendation/recommendations/{recommendation.id}",
json={},
headers={"Authorization": f"Bearer {token_BDE}"},
)
assert response.status_code == 204


def test_edit_for_non_existing_recommendation():
response = client.patch(
"/recommendation/recommendations/false_id",
json={"title": "Nouveau titre"},
Expand All @@ -118,6 +130,9 @@ def test_delete_recommendation():
headers={"Authorization": f"Bearer {token_BDE}"},
)
assert response.status_code == 204


def test_delete_for_non_existing_recommendation():
response = client.delete(
"/recommendation/recommendations/false_id",
headers={"Authorization": f"Bearer {token_BDE}"},
Expand Down

0 comments on commit 66c7ec6

Please sign in to comment.