Skip to content

Commit

Permalink
Make a couple of test assertions more specific
Browse files Browse the repository at this point in the history
It's not enough to just test the status code, you also have to test
_why_ that status code was returned. Otherwise the test could be passing
even though the code isn't returning the expected response.
  • Loading branch information
seanh committed Nov 1, 2024
1 parent 7bf82fe commit 3d02964
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/functional/api/groups/update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def test_it_returns_http_400_with_invalid_payload_and_user_token(
)

assert res.status_code == 400
assert res.json == {
"reason": "name: 'Oooopoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' is too long",
"status": "failure",
}

def test_it_returns_http_400_if_groupid_set_on_default_authority_and_user_token(
self, app, token_auth_header, first_party_group, first_party_user, db_session
Expand All @@ -121,6 +125,10 @@ def test_it_returns_http_400_if_groupid_set_on_default_authority_and_user_token(
)

assert res.status_code == 400
assert res.json == {
"reason": "groupid: '3434kjkjk' does not match \"^group:([a-zA-Z0-9._\\\\-+!~*()']{1,1024})@(.*)$\"",
"status": "failure",
}

def test_it_returns_http_404_if_no_authenticated_user(self, app, first_party_group):
group = {"name": "My Group"}
Expand Down

0 comments on commit 3d02964

Please sign in to comment.