From 3d02964431e5842e6708fd3c38a7961fa8256df3 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Fri, 1 Nov 2024 17:34:44 +0000 Subject: [PATCH] Make a couple of test assertions more specific 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. --- tests/functional/api/groups/update_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/functional/api/groups/update_test.py b/tests/functional/api/groups/update_test.py index 9cd94c5256b..faed7250907 100644 --- a/tests/functional/api/groups/update_test.py +++ b/tests/functional/api/groups/update_test.py @@ -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 @@ -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"}