From 6d074184e530bc0510e0900fe870a1d9212b04fe Mon Sep 17 00:00:00 2001 From: "carlos.vdr" Date: Thu, 16 Nov 2023 11:38:26 -0600 Subject: [PATCH] fix: Changed fetch mode and added another fixture Signed-off-by: carlos.vdr --- autoagora/price_save_state_db.py | 3 +-- tests/test_price_save_state_db.py | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/autoagora/price_save_state_db.py b/autoagora/price_save_state_db.py index a4c091b..330912c 100644 --- a/autoagora/price_save_state_db.py +++ b/autoagora/price_save_state_db.py @@ -78,9 +78,8 @@ async def load_state(self, subgraph: str) -> Optional[SaveState]: """ ).format(subgraph_hash=subgraph) ) - row = await row.fetchall() + row = await row.fetchone() if row: - row = row[0] return SaveState( last_update=row[0], # type: ignore mean=row[1], # type: ignore diff --git a/tests/test_price_save_state_db.py b/tests/test_price_save_state_db.py index cbd1cab..69e68cb 100644 --- a/tests/test_price_save_state_db.py +++ b/tests/test_price_save_state_db.py @@ -11,7 +11,7 @@ class TestPriceSaveStateDB: @pytest.fixture - async def pssdb(self, postgresql): + async def pgpool(self, postgresql): conn_string = ( f"host={postgresql.info.host} " f"dbname={postgresql.info.dbname} " @@ -25,9 +25,13 @@ async def pssdb(self, postgresql): ) await pool.open() await pool.wait() + yield pool + await pool.close() - pssdb_ = price_save_state_db.PriceSaveStateDB(pool) - return pssdb_ + @pytest.fixture + async def pssdb(self, pgpool): + pssdb_ = price_save_state_db.PriceSaveStateDB(pgpool) + yield pssdb_ async def test_create_write_read(self, pssdb): random.seed(42)