Skip qt tests on missing brokers.ini entry

kivy_mainline_and_py3.8
Tyler Goodlet 2018-11-22 19:12:14 -05:00
parent eaa2a9b05d
commit e1d6edb3ee
2 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,12 @@
import pytest
@pytest.fixture
def brokerconf():
from piker.brokers import config
return config.load()[0]
@pytest.fixture
def us_symbols():
return ['TSLA', 'AAPL', 'CGC', 'CRON']

View File

@ -6,6 +6,15 @@ import time
import trio
from trio.testing import trio_test
from piker.brokers import questrade as qt
import pytest
@pytest.fixture(autouse=True)
def check_qt_conf_section(brokerconf):
"""Skip this module's tests if we have not quetrade API creds.
"""
if not brokerconf.has_section('questrade'):
pytest.skip("No questrade API credentials available")
# stock quote
@ -66,7 +75,6 @@ _ex_contract = {
}
def match_packet(symbols, quotes):
"""Verify target ``symbols`` match keys in ``quotes`` packet.
"""
@ -158,7 +166,7 @@ async def test_option_quote_latency(tmx_symbols):
for _ in range(10):
# chains quote for all symbols
start = time.time()
quotes = await client.option_chains(contract)
await client.option_chains(contract)
took = time.time() - start
print(f"Request took {took}")
assert took <= expected_latency