|
20 | 20 | LIVE_REPLAY_EXCHANGE = "bitmex" |
21 | 21 | LIVE_REPLAY_FROM = "2019-05-01T00:00:00.000Z" |
22 | 22 | LIVE_REPLAY_TO = "2019-05-01T00:01:00.000Z" |
| 23 | +LIVE_EMPTY_REPLAY_EXCHANGE = "binance" |
| 24 | +LIVE_EMPTY_REPLAY_FROM = "2019-06-01T00:00:00.000Z" |
| 25 | +LIVE_EMPTY_REPLAY_TO = "2019-06-01T00:01:00.000Z" |
23 | 26 |
|
24 | 27 |
|
25 | 28 | def _live_replay_filters(): |
26 | 29 | return [Channel("trade", ["BTCUSD"])] |
27 | 30 |
|
28 | 31 |
|
| 32 | +def _live_empty_replay_filters(): |
| 33 | + return [Channel("trade", ["batpax"])] |
| 34 | + |
| 35 | + |
29 | 36 | class _FakeSession: |
30 | 37 | async def __aenter__(self): |
31 | 38 | return object() |
@@ -90,6 +97,23 @@ async def test_replay_auto_cleanup_removes_live_processed_slices(tmp_path: Path) |
90 | 97 | assert not day_dir.exists() |
91 | 98 |
|
92 | 99 |
|
| 100 | +@pytest.mark.live |
| 101 | +@pytest.mark.asyncio |
| 102 | +async def test_replay_live_empty_slice_yields_no_messages(tmp_path: Path): |
| 103 | + cache_dir = tmp_path / "cache" |
| 104 | + results = [] |
| 105 | + async for item in replay( |
| 106 | + exchange=LIVE_EMPTY_REPLAY_EXCHANGE, |
| 107 | + from_date=LIVE_EMPTY_REPLAY_FROM, |
| 108 | + to_date=LIVE_EMPTY_REPLAY_TO, |
| 109 | + filters=_live_empty_replay_filters(), |
| 110 | + cache_dir=str(cache_dir), |
| 111 | + ): |
| 112 | + results.append(item) |
| 113 | + |
| 114 | + assert results == [] |
| 115 | + |
| 116 | + |
93 | 117 | def test_replay_rejects_invalid_date_order(): |
94 | 118 | async def collect(): |
95 | 119 | async for _ in replay(exchange="bitmex", from_date="2019-06-02", to_date="2019-06-01"): |
|
0 commit comments