Skip to content

Commit

Permalink
Return decisions in API tests
Browse files Browse the repository at this point in the history
This allows Schemathesis to actually test the response body. These tests
were not failing because none of the response attributes are actually
required.
  • Loading branch information
cbguder committed Dec 27, 2023
1 parent c5de875 commit 5561dba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from aioresponses import aioresponses

from tests.fixtures.mock_factory import get_mocked_geolocation_factory
from tests.fixtures.mock_decision import mock_decision_2

__FACTORY = get_mocked_geolocation_factory()
with patch("app.geolocation.factory.Factory.get_instance", return_value=__FACTORY):
Expand All @@ -13,6 +14,15 @@
schema = schemathesis.from_path("openapi/openapi.yml", app=app)


MOCK_DECISIONS_RESPONSE = {
"user": {
"key": "{12345678-8901-2345-aaaa-bbbbbbcccccc}",
},
"decisions": {
"spocs": [mock_decision_2]
}
}

@responses.activate
@schema.parametrize()
def test_api(case: schemathesis.Case) -> None:
Expand All @@ -21,7 +31,7 @@ def test_api(case: schemathesis.Case) -> None:

with aioresponses() as m:
# Mock call to decisions API
m.post("https://e-10250.adzerk.net/api/v2", payload={"decisions": {}})
m.post("https://e-10250.adzerk.net/api/v2", payload=MOCK_DECISIONS_RESPONSE)

# Call Pocket Proxy and validate response
response = case.call_asgi()
Expand Down

0 comments on commit 5561dba

Please sign in to comment.