lbry-sdk/tests/integration/other/test_exchange_rate_manager.py

23 lines
940 B
Python
Raw Normal View History

from decimal import Decimal
from lbry.testcase import AsyncioTestCase
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager, FEEDS
class TestExchangeRateManager(AsyncioTestCase):
async def test_exchange_rate_manager(self):
# TODO: re-enable cryptonator.com
2021-01-01 20:14:08 +01:00
# TODO: this uses real exchange rate feeds... update to use mocks
manager = ExchangeRateManager(FEEDS)
manager.start()
self.addCleanup(manager.stop)
for feed in manager.market_feeds:
self.assertFalse(feed.is_online)
self.assertIsNone(feed.rate)
await manager.wait()
for feed in manager.market_feeds:
self.assertTrue(feed.is_online)
self.assertIsInstance(feed.rate, ExchangeRate)
lbc = manager.convert_currency('USD', 'LBC', Decimal('0.01'))
2021-01-01 20:14:08 +01:00
self.assertGreaterEqual(lbc, 0.01)
self.assertLessEqual(lbc, 10.0)