Skip to content

Commit

Permalink
tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 committed May 28, 2024
1 parent a964dfb commit 0182d31
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Python application

on:
push:
branches: [ master ]
branches: [ master, advanced-streamer ]
pull_request:
branches: [ master ]
branches: [ master, advanced-streamer ]

jobs:
build:
Expand Down
1 change: 0 additions & 1 deletion tastytrade/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import requests
from pydantic import BaseModel

from tastytrade import logger
from tastytrade.order import (InstrumentType, NewComplexOrder, NewOrder,
OrderStatus, PlacedComplexOrder, PlacedOrder,
PlacedOrderResponse, PriceEffect)
Expand Down
2 changes: 1 addition & 1 deletion tastytrade/streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ async def listen(self, event_type: EventType) -> AsyncIterator[Event]:
def get_event_nowait(self, event_type: EventType) -> Optional[Event]:
"""
Using the existing subscriptions, pulls an event of the given type and
returns it. if the queue is empty None is returned.
returns it. If the queue is empty None is returned.
:param event_type: the type of event to get
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def cert_session(get_cert_credentials):

@pytest.fixture(scope='session')
def cert_account(cert_session):
return Account.get_accounts(cert_session)[1]
return Account.get_account(cert_session, '5WZ97189')


def test_get_account(session, account):
Expand Down
17 changes: 4 additions & 13 deletions tests/test_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,14 @@ async def test_dxlink_streamer(session):
async with DXLinkStreamer(session) as streamer:
subs = ['SPY', 'AAPL']
await streamer.subscribe(EventType.QUOTE, subs)
# this symbol doesn't exist
await streamer.subscribe(EventType.TRADE, ['QQQQ'])
start_date = datetime.today() - timedelta(days=30)
await streamer.subscribe_candle(subs, '1d', start_date)
_ = await streamer.get_event(EventType.CANDLE)
assert streamer.get_event_nowait(EventType.CANDLE) is not None
assert streamer.get_event_nowait(EventType.TRADE) is None
async for _ in streamer.listen(EventType.QUOTE):
break
await streamer.unsubscribe_candle(subs[0], '1d')
await streamer.unsubscribe(EventType.QUOTE, subs[1])


@pytest.mark.asyncio
async def test_dxlink_streamer_nowait(session):
async with DXLinkStreamer(session) as streamer:
subs_not_none = ['SPY']
subs_none = ['QQQQ']
await streamer.subscribe(EventType.TRADE, subs_not_none)
await streamer.subscribe(EventType.QUOTE, subs_none)
assert streamer.get_event_nowait(EventType.TRADE) is not None
assert streamer.get_event_nowait(EventType.QUOTE) is None
await streamer.unsubscribe(EventType.TRADE, subs_not_none)
await streamer.unsubscribe(EventType.QUOTE, subs_none)

0 comments on commit 0182d31

Please sign in to comment.