Skip to content

Commit

Permalink
test(eligibility): add test for when API returns unexpected status code
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed May 11, 2022
1 parent 36b9c8e commit 9e4e0cf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/pytest/eligibility/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,21 @@ def raise_exception():

with pytest.raises(ApiError):
confirm(request)


@httpretty.activate(verbose=True, allow_net_connect=False)
@pytest.mark.django_db
def test_confirm_failure_unexpected_status_code(mocker, rf):
agency, verifier = set_verifier(mocker)

httpretty.register_uri(httpretty.GET, "http://localhost/verify", status=404)

path = reverse("eligibility:confirm")
body = {"sub": "A1234567", "name": "Garcia"}
request = rf.post(path, body)

initialize_request(request)
session.update(request, agency=agency, verifier=verifier, oauth_token="token")

with pytest.raises(ApiError, match=r"Unexpected eligibility"):
confirm(request)

0 comments on commit 9e4e0cf

Please sign in to comment.