mirror of
https://github.com/usestrix/strix.git
synced 2026-10-14 04:08:06 +00:00
Unwrap chunk envelopes in spend-request poll output
This commit is contained in:
parent
995ba47e05
commit
24a5a362fb
2 changed files with 17 additions and 1 deletions
|
|
@ -444,7 +444,14 @@ def _spend_request_records(stdout: str) -> list[dict[str, Any]]:
|
|||
records: list[dict[str, Any]] = []
|
||||
for candidate in _embedded_json_documents((stdout or "").strip()):
|
||||
items = candidate if isinstance(candidate, list) else [candidate]
|
||||
records.extend(cast("dict[str, Any]", item) for item in items if isinstance(item, dict))
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
record = cast("dict[str, Any]", item)
|
||||
data = record.get("data")
|
||||
if isinstance(data, dict):
|
||||
record = cast("dict[str, Any]", data)
|
||||
records.append(record)
|
||||
return records
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,15 @@ def test_final_spend_request_status_reads_the_last_poll_line() -> None:
|
|||
assert billing._final_spend_request_status("") is None
|
||||
|
||||
|
||||
def test_final_spend_request_status_unwraps_chunk_envelopes() -> None:
|
||||
stdout = (
|
||||
'{"type":"chunk","data":{"id":"lsrq_9","status":"pending_approval"}}\n'
|
||||
'{"type":"chunk","data":{"id":"lsrq_9","status":"approved"}}\n'
|
||||
'{"type":"done","ok":true,"meta":{"command":"spend-request retrieve"}}\n'
|
||||
)
|
||||
assert billing._final_spend_request_status(stdout) == "approved"
|
||||
|
||||
|
||||
def test_prepare_link_wallet_skips_login_when_connected(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(billing, "_link_wallet_authenticated", lambda _npx: True)
|
||||
assert billing._prepare_link_wallet(Console(), "npx", as_json=True) is None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue