diff --git a/app/main.py b/app/main.py index b86a4de..b0211ab 100644 --- a/app/main.py +++ b/app/main.py @@ -7414,7 +7414,12 @@ async def fetch_account_by_slug(slug: str) -> dict | None: "... on Individual { email isIncognito } } }") try: async with httpx.AsyncClient(timeout=30.0) as client: - data = await _oc_graphql_post(client, {"query": query, "variables": {"slug": slug}}) + # _oc_graphql_post returns the RESPONSE (it is a retrying wrapper + # around client.post), so the JSON is read here. Getting this wrong + # is invisible to a stubbed test and fatal in the container: the + # first live run raised 'Response object has no attribute get'. + resp = await _oc_graphql_post(client, {"query": query, "variables": {"slug": slug}}) + data = resp.json() except Exception as e: # read failure: report, never raise logger.warning("OC account lookup failed for slug %s: %s", slug, e) return None diff --git a/tests/test_resolve_payer.py b/tests/test_resolve_payer.py index 363e82e..03f6bac 100644 --- a/tests/test_resolve_payer.py +++ b/tests/test_resolve_payer.py @@ -49,10 +49,21 @@ def check(cond, msg): REAL_POST = m._oc_graphql_post +class FakeResponse: + """Mirror httpx.Response: the REAL _oc_graphql_post returns a response, not + parsed JSON. An earlier stub returned a dict, the test passed, and the first + live call died with 'Response object has no attribute get' — a stub that does + not match the real return shape certifies nothing.""" + def __init__(self, payload): + self._payload = payload + def json(self): + return self._payload + + def fake_post(payload): - """Stand in for OC's GraphQL endpoint.""" + """Stand in for OC's GraphQL endpoint (the response wrapper, not the JSON).""" async def _post(client, json_body, headers=None, attempts=2): - return payload + return FakeResponse(payload) return _post