From f96d6a04b618312d10b7ef3d7654114283bf785a Mon Sep 17 00:00:00 2001 From: Esmeralda Gallardo Date: Wed, 22 Feb 2023 13:28:07 -0300 Subject: [PATCH] Fixed UnboundLocalError on _ahab. Added test for marketstore's initialization --- piker/data/_ahab.py | 12 ++++++------ tests/test_databases.py | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/piker/data/_ahab.py b/piker/data/_ahab.py index 2ab8680e..bb1d451d 100644 --- a/piker/data/_ahab.py +++ b/piker/data/_ahab.py @@ -324,13 +324,13 @@ async def open_ahabd( with trio.move_on_after(start_timeout): found = await cntr.process_logs_until(start_lambda) - if not found and dcntr not in client.containers.list(): - for entry in cntr.seen_so_far: - log.info(entry) + if not found and dcntr not in client.containers.list(): + for entry in cntr.seen_so_far: + log.info(entry) - raise RuntimeError( - f'Failed to start {dcntr.id} check logs deats' - ) + raise RuntimeError( + f'Failed to start {dcntr.id} check logs deats' + ) await ctx.started(( cntr.cntr.id, diff --git a/tests/test_databases.py b/tests/test_databases.py index 907b716a..dac64b35 100644 --- a/tests/test_databases.py +++ b/tests/test_databases.py @@ -7,28 +7,48 @@ from piker._daemon import Services from piker.log import get_logger from elasticsearch import Elasticsearch +from piker.data import marketstore + +def test_marketstore( + open_test_pikerd: AsyncContextManager, +): + + ''' + Verify marketstore starts correctly + + ''' + log = get_logger(__name__) + + async def main(): + # port = 5995 + + async with ( + open_test_pikerd( + loglevel='info', + tsdb=True + ) as (s, i, pikerd_portal, services), + marketstore.get_client() as client + ): + + assert ( + len(await client.server_version()) == + len('3862e9973da36cfc6004b88172c08f09269aaf01') + ) -# def test_marketstore( open_test_pikerd: AsyncContextManager): - -''' -Verify marketstore starts and closes correctly - -''' + trio.run(main) def test_elasticsearch( open_test_pikerd: AsyncContextManager, ): ''' - Verify elasticsearch starts and closes correctly + Verify elasticsearch starts correctly ''' log = get_logger(__name__) - # log.info('#################### Starting test ####################') - async def main(): port = 19200