Skip to content

Commit

Permalink
fix: Changed fetch mode and added another fixture
Browse files Browse the repository at this point in the history
Signed-off-by: carlos.vdr <[email protected]>
  • Loading branch information
carlosvdr committed Nov 16, 2023
1 parent 7cd6f52 commit 6d07418
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions autoagora/price_save_state_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions tests/test_price_save_state_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} "
Expand All @@ -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)
Expand Down

0 comments on commit 6d07418

Please sign in to comment.