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

22 lines
812 B
Python
Raw Normal View History

2019-12-15 07:02:18 +01:00
from decimal import Decimal
2019-12-31 21:30:13 +01:00
from lbry.testcase import AsyncioTestCase
2019-12-15 07:06:43 +01:00
from lbry.extras.daemon.exchange_rate_manager import ExchangeRate, ExchangeRateManager
2019-12-15 07:02:18 +01:00
class TestExchangeRateManager(AsyncioTestCase):
async def test_exchange_rate_manager(self):
manager = ExchangeRateManager()
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'))
self.assertGreaterEqual(lbc, 0.1)
self.assertLessEqual(lbc, 10.0)