def test_missing_feed(self): # test when a feed is missing for conversion fee = Fee({ 'currency': 'USD', 'amount': 1.0, 'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9" }) rates = { 'BTCLBC': { 'spot': 1.0, 'ts': util.DEFAULT_ISO_TIME + 1 }, } market_feeds = [BTCLBCFeed()] manager = DummyExchangeRateManager(market_feeds, rates) with self.assertRaises(Exception): manager.convert_currency(fee.currency, "LBC", fee.amount)
def test_fee_converts_to_lbc(self): fee = Fee({ 'currency': 'USD', 'amount': 10.0, 'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9" }) rates = { 'BTCLBC': { 'spot': 3.0, 'ts': util.DEFAULT_ISO_TIME + 1 }, 'USDBTC': { 'spot': 2.0, 'ts': util.DEFAULT_ISO_TIME + 2 } } market_feeds = [BTCLBCFeed(), USDBTCFeed()] manager = DummyExchangeRateManager(market_feeds, rates) result = manager.convert_currency(fee.currency, "LBC", fee.amount) self.assertEqual(60.0, result)