Skip to content

Commit 41426be

Browse files
aniani
authored andcommitted
increase coverage a bit
1 parent 6fdcec0 commit 41426be

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

examples/read_hermes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ async def get_hermes_prices():
1515

1616
prices_latest = await hermes_client.get_all_prices(version=version_http)
1717

18-
sd = list(prices_latest.keys())[0]
19-
2018
for feed_id, price_feed in prices_latest.items():
2119
print("Initial prices")
2220
print(f"Feed ID: {feed_id}, Price: {price_feed['price'].price}, Confidence: {price_feed['price'].conf}, Time: {price_feed['price'].publish_time}")

tests/test_hermes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from mock import AsyncMock
66

7-
from pythclient.hermes import HermesClient, PriceFeed
7+
from pythclient.hermes import HermesClient, PriceFeed, parse_unsupported_version
88

99
@pytest.fixture
1010
def feed_ids():
@@ -72,6 +72,12 @@ def data_v2():
7272
]
7373
}
7474

75+
def test_parse_unsupported_version():
76+
with pytest.raises(ValueError):
77+
parse_unsupported_version(3)
78+
with pytest.raises(TypeError):
79+
parse_unsupported_version("3")
80+
7581
@pytest.fixture
7682
def mock_get_price_feed_ids(mocker: MockerFixture):
7783
async_mock = AsyncMock()
@@ -87,8 +93,11 @@ async def test_hermes_add_feed_ids(hermes_client: HermesClient, mock_get_price_f
8793
feed_ids_pre = hermes_client.feed_ids
8894
pending_feed_ids_pre = hermes_client.pending_feed_ids
8995

90-
hermes_client.add_feed_ids(feed_ids)
96+
# Add feed_ids to the client in duplicate
97+
for _ in range(3):
98+
hermes_client.add_feed_ids(feed_ids)
9199

100+
assert len(set(hermes_client.feed_ids)) == len(hermes_client.feed_ids)
92101
assert set(hermes_client.feed_ids) == set(feed_ids_pre + feed_ids)
93102
assert set(hermes_client.pending_feed_ids) == set(pending_feed_ids_pre + feed_ids)
94103

0 commit comments

Comments
 (0)