Skip to content

Instantly share code, notes, and snippets.

@mrzechonek
Created November 9, 2017 17:38
Show Gist options
  • Save mrzechonek/df22ad89e72ebadb41cab0e0f8893a09 to your computer and use it in GitHub Desktop.
Save mrzechonek/df22ad89e72ebadb41cab0e0f8893a09 to your computer and use it in GitHub Desktop.
@pytest.mark.asyncio
@pytest.mark.django_db
async def test_request(zmq_client, feed_task, test_month):
stocks, sessions, quotes = test_month
subscription = zmq_client.subscribe('quotes', 'quote')
reply, count = await zmq_client._async(feed_task.request,
start=datetime(2017, 1, 1),
end=datetime(2017, 1, 3))
assert reply
assert count == 2
for date in (datetime(2017, 1, 1), datetime(2017, 1, 2)):
*_, feed = await asyncio.wait_for(pop(subscription, schema=FeedSchema()), timeout=1.0)
assert feed.session.date == date.date()
assert set(feed.stock_data.keys()) == set(s.id for s in stocks.values())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment