Skip to content

Commit 1415e4a

Browse files
Replace list public trades in integration tests
The list public trades test was removed because that endpoint is no longer available. Instead, we now test receiving public trades with a filter set. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 14810ed commit 1415e4a

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

integration_tests/test_api.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,6 @@ async def test_list_gridpool_trades(set_up: dict[str, Any]) -> None:
352352
assert len(trades) >= 1
353353

354354

355-
async def test_list_public_trades(set_up: dict[str, Any]) -> None:
356-
"""Test listing public trades."""
357-
delivery_period = DeliveryPeriod(
358-
start=datetime.fromisoformat("2024-06-10T10:00:00+00:00"),
359-
duration=timedelta(minutes=15),
360-
)
361-
362-
public_trades = []
363-
counter = 0
364-
async for trade in set_up["client"].list_public_trades(
365-
delivery_period=delivery_period
366-
):
367-
public_trades.append(trade)
368-
counter += 1
369-
if counter == 10:
370-
break
371-
372-
assert len(public_trades) == 10, "Failed to retrieve 10 public trades"
373-
374-
375355
async def test_gridpool_orders_stream(set_up: dict[str, Any]) -> None:
376356
"""Test gridpool orders stream."""
377357
stream = set_up["client"].gridpool_orders_stream(GRIDPOOL_ID)
@@ -403,6 +383,35 @@ async def test_receive_public_trades(set_up: dict[str, Any]) -> None:
403383
pytest.fail("Streaming timed out, no trade received in 15 seconds")
404384

405385

386+
async def test_receive_public_trades_filter(set_up: dict[str, Any]) -> None:
387+
"""Test receive public trades with filter set."""
388+
start_time = datetime.now(timezone.utc).replace(second=0, microsecond=0)
389+
start_time += timedelta(minutes=30 - start_time.minute % 15) # next 15-minute mark
390+
391+
delivery_period = DeliveryPeriod(start=start_time, duration=timedelta(minutes=15))
392+
393+
price = Price(amount=Decimal("808"), currency=Currency.EUR)
394+
395+
stream = set_up["client"].receive_public_trades(
396+
delivery_period=delivery_period,
397+
)
398+
receiver = stream.new_receiver()
399+
400+
_ = await create_test_order(
401+
set_up, delivery_period=delivery_period, side=MarketSide.BUY, price=price
402+
)
403+
_ = await create_test_order(
404+
set_up, delivery_period=delivery_period, side=MarketSide.SELL, price=price
405+
)
406+
407+
try:
408+
public_trade = await asyncio.wait_for(anext(receiver), timeout=15)
409+
assert public_trade, "Failed to receive public trade"
410+
assert public_trade.delivery_period.start == delivery_period.start
411+
except asyncio.TimeoutError:
412+
pytest.fail("Streaming timed out, no public trade received in 15 seconds")
413+
414+
406415
async def test_gridpool_trades_stream(set_up: dict[str, Any]) -> None:
407416
"""Test gridpool trades stream."""
408417
stream = set_up["client"].gridpool_trades_stream(GRIDPOOL_ID)

0 commit comments

Comments
 (0)