Skip to content

Commit

Permalink
better error reporting in signup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johanlundberg committed Dec 2, 2024
1 parent 530174d commit 5f2c3a8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/eduid/webapp/signup/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,19 +735,25 @@ def _accept_invite(

logger.info(f"Making request to {endpoint}")
response = client.post(f"{endpoint}", data=json.dumps(data), content_type=self.content_type_json)
assert response is not None, "response unexpected None"

logger.info(f"Request to {endpoint} result: {response}")

if response.status_code != 200:
return SignupResult(url=endpoint, reached_state=SignupState.S1_ACCEPT_INVITE, response=response)

assert response.json is not None, "response.json unexpected None"
if expect_success:
assert (
response.json.get("error", False) is False
), f"expect_success {expect_success} but got error={response.json.get('error')}"
if not expected_payload:
assert self.get_response_payload(response)["state"]["tou"]["completed"] is False
assert self.get_response_payload(response)["state"]["captcha"]["completed"] is False
assert self.get_response_payload(response)["state"]["email"]["address"] == email
assert self.get_response_payload(response)["state"]["email"]["completed"] is email_verified
assert self.get_response_payload(response)["state"]["user_created"] is False
payload = self.get_response_payload(response)
assert payload["state"]["tou"]["completed"] is False
assert payload["state"]["captcha"]["completed"] is False
assert payload["state"]["email"]["address"] == email
assert payload["state"]["email"]["completed"] is email_verified
assert payload["state"]["user_created"] is False
with client.session_transaction() as sess:
assert sess.signup.invite.invite_code == invite_code

Expand Down

0 comments on commit 5f2c3a8

Please sign in to comment.