Skip to content

Commit

Permalink
Add missing test after a986d4
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Apr 7, 2023
1 parent dd8b7bf commit 8b84bfd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/api/handlers/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,17 @@ async def test_get_user_rules_generated(
assert "generated_last_week" in result
assert result["generated_last_week"] == count

@pytest.mark.parametrize("testcase", ("happy-path", "wrong-user"))
@pytest.mark.parametrize("testcase", ("happy-path", "wrong-user", "no-rule"))
def test_get_user_rule(self, testcase, client, api_identity, db_rule):
username = api_identity.name
if testcase == "wrong-user":
username = f"not-really-{username}"
if testcase == "no-rule":
rule_id = 4242
else:
rule_id = db_rule.id

response = client.get(f"{self.path}/{username}/rules/{db_rule.id}")
response = client.get(f"{self.path}/{username}/rules/{rule_id}")

if testcase == "happy-path":
assert response.status_code == status.HTTP_200_OK
Expand All @@ -222,6 +226,9 @@ def test_get_user_rule(self, testcase, client, api_identity, db_rule):
elif testcase == "wrong-user":
assert response.status_code == status.HTTP_403_FORBIDDEN
assert isinstance(response.json()["detail"], str)
elif testcase == "no-rule":
assert response.status_code == status.HTTP_404_NOT_FOUND
assert isinstance(response.json()["detail"], str)

@pytest.mark.parametrize(
"testcase",
Expand Down

0 comments on commit 8b84bfd

Please sign in to comment.