Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
increase coverage a bit
  • Loading branch information
ani authored and ani committed Feb 21, 2024
commit 41426bea9fa7a2c87323f40d24f950dcff4f5adf
2 changes: 0 additions & 2 deletions examples/read_hermes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ async def get_hermes_prices():

prices_latest = await hermes_client.get_all_prices(version=version_http)

sd = list(prices_latest.keys())[0]

for feed_id, price_feed in prices_latest.items():
print("Initial prices")
print(f"Feed ID: {feed_id}, Price: {price_feed['price'].price}, Confidence: {price_feed['price'].conf}, Time: {price_feed['price'].publish_time}")
Expand Down
13 changes: 11 additions & 2 deletions tests/test_hermes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mock import AsyncMock

from pythclient.hermes import HermesClient, PriceFeed
from pythclient.hermes import HermesClient, PriceFeed, parse_unsupported_version

@pytest.fixture
def feed_ids():
Expand Down Expand Up @@ -72,6 +72,12 @@ def data_v2():
]
}

def test_parse_unsupported_version():
with pytest.raises(ValueError):
parse_unsupported_version(3)
with pytest.raises(TypeError):
parse_unsupported_version("3")

@pytest.fixture
def mock_get_price_feed_ids(mocker: MockerFixture):
async_mock = AsyncMock()
Expand All @@ -87,8 +93,11 @@ async def test_hermes_add_feed_ids(hermes_client: HermesClient, mock_get_price_f
feed_ids_pre = hermes_client.feed_ids
pending_feed_ids_pre = hermes_client.pending_feed_ids

hermes_client.add_feed_ids(feed_ids)
# Add feed_ids to the client in duplicate
for _ in range(3):
hermes_client.add_feed_ids(feed_ids)

assert len(set(hermes_client.feed_ids)) == len(hermes_client.feed_ids)
assert set(hermes_client.feed_ids) == set(feed_ids_pre + feed_ids)
assert set(hermes_client.pending_feed_ids) == set(pending_feed_ids_pre + feed_ids)

Expand Down