test(ws): live ticker data assertion on high-traffic channel (Closes #181) - #182
Merged
Conversation
Sporadic-channel live tests treat a quiet window as pass. Add ticker (BTC-USDT@binance spot) test asserting a real data msg (s==BTC-USDT, has p) arrives within 30s; quiet window is a FAIL. Proves SDK decodes+yields payload end-to-end. integration marker, needs DATAMAXI_API_KEY.
…lanes premium high-traffic (24/7) -> hard data-assert (key match, premium field present; value nullable so not asserted). forex/funding-rate/open-interest sporadic -> quiet window=PASS, shape-checked when a msg arrives (forex s/r; funding/OI non-empty dict, shape not observable live). Widen module docstring.
Futures sibling of the spot ticker test; high-traffic -> silence=FAIL. Asserts s==BTC-USDT, has p, and m==futures to prove the futures path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #181
Summary
The live WS lane only covered sporadic channels (
/liquidation,/announcement/listing) where a quiet window (no event before timeout) is a pass — that verifies connect + auth + SUBSCRIBE but never proves the SDK decodes and yields a real payload. This PR adds coverage across more channels, choosing the test type per channel's real cadence (probed live):High-traffic → HARD data-assertion (silence = FAIL):
tickerspot (BTC-USDT@binance) — assertsmsg["s"]=="BTC-USDT","p" in msgwithin 30s.tickerfutures (BTC-USDT@binance,market="futures") — same, plusmsg["m"]=="futures"to prove the futures path (not spot) is exercised.premium(binance:upbit:bitcoin:USDT:KRW:spot:spot, 24/7) — assertsmsg["key"]==...,"premium" in msgwithin 30s (thepremiumvalue is nullable, so identity fields are asserted, not the value).Sporadic → quiet-window TOLERANT (silence = PASS) + shape-check-if-present:
forex(USD-KRW) — 20s bound (first tick can lag ~14s; FX spot is quiet on weekends/off-hours). If a tick arrives:msg["s"]=="USD-KRW","r" in msg.funding_rate(BTC-USDT@binance) — on-change/snapshot, sporadic. If a msg arrives: non-empty data dict (shape not observable live).open_interest(BTC-USDT@binance) — sporadic. Same minimal shape check.Quiet-tolerant tests mirror the existing
test_ws_liquidation_...structure (TimeoutError→ PASS). Acks are filtered by the client reader, so the first yielded message is always a real payload. Additive: new test fns +_DATA_TIMEOUT/_FOREX_TIMEOUTconstants + widened module docstring; existing tests untouched. All under theintegrationmarker (needsDATAMAXI_API_KEY), deselected from the keyless lane, consistent with the non-blocking (continue-on-error) live lane.Test plan
DATAMAXI_API_KEY=... pytest tests/test_ws_live.py -v -m integration→ 8 passed (ticker spot/futures + premium receive real data; forex/funding/OI pass via quiet window or shape-check).pytest tests/ -m "not integration"→ 226 passed, all live tests deselected (115 deselected).black+flake8clean.