From 85d4cd0fcf92113b544bca9421688b57258d70f0 Mon Sep 17 00:00:00 2001 From: Peter Jung Date: Wed, 26 Jun 2024 14:26:22 +0200 Subject: [PATCH] Fix get omen market by id (#288) --- .../markets/omen/omen_subgraph_handler.py | 4 +++- pyproject.toml | 2 +- tests/markets/omen/test_omen_subgraph_handler.py | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py b/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py index 53752d4d..c88a25b4 100644 --- a/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +++ b/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py @@ -383,7 +383,9 @@ def _parse_items_from_json( for result_chunk in result: for k, v in result_chunk.items(): # subgrounds might pack all items as a list, indexed by a key, or pack it as a dictionary (if one single element) - if isinstance(v, dict): + if v is None: + continue + elif isinstance(v, dict): items.extend([v]) else: items.extend(v) diff --git a/pyproject.toml b/pyproject.toml index bfa767ba..9813b040 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prediction-market-agent-tooling" -version = "0.39.2" +version = "0.39.3" description = "Tools to benchmark, deploy and monitor prediction market agents." authors = ["Gnosis"] readme = "README.md" diff --git a/tests/markets/omen/test_omen_subgraph_handler.py b/tests/markets/omen/test_omen_subgraph_handler.py index 9f41dd66..ee5e3dcc 100644 --- a/tests/markets/omen/test_omen_subgraph_handler.py +++ b/tests/markets/omen/test_omen_subgraph_handler.py @@ -279,3 +279,9 @@ def test_get_markets_id_in() -> None: ) assert len(markets) == 1 assert markets[0].id == market_id + + +def test_omen_get_non_existing_market_by_id() -> None: + with pytest.raises(ValueError) as e: + OmenSubgraphHandler().get_omen_market_by_market_id(HexAddress(HexStr("0x123"))) + assert "Fetched wrong number of markets. Expected 1 but got 0" in str(e)