resolve payer: read the response's JSON (the stub hid this)
ci/woodpecker/push/woodpecker Pipeline was canceled
ci/woodpecker/push/woodpecker Pipeline was canceled
_oc_graphql_post returns the RESPONSE — it is a retrying wrapper around client.post — so fetch_account_by_slug has to call .json() on it. My unit test stubbed it as a dict, so the test passed and the first live call in the container died with "Response object has no attribute get". The test now stubs the real shape (a response wrapper with .json()). Folding it in here rather than hiding it: a stub that does not match the real return shape certifies nothing.
This commit is contained in:
1 parent
cbf5a6870b
commit
9c10e627fc
2 files changed
+19
-3
No files matched your search
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user