def test_fetch_price__naive_time_no_timeozne(self, fetch_cached): fetch_cached.return_value = SourcePrice( D('125.00'), datetime.datetime(2015, 11, 22, 16, 0, 0), 'JPY') dprice = price.DatedPrice('JPY', 'USD', datetime.date(2015, 11, 22), None) with self.assertRaises(ValueError): price.fetch_price(dprice._replace(sources=[ price.PriceSource(yahoo, 'USDJPY', False)]), False)
def test_fetch_price__swapped(self): entry = price.fetch_price( self.dprice._replace( sources=[find_prices.PriceSource(yahoo, 'USDJPY', True)]), True) self.assertEqual(('USD', 'JPY'), (entry.currency, entry.amount.currency)) self.assertEqual(D('125.00'), entry.amount.number)
def test_fetch_price__inverted(self): entry = price.fetch_price( self.dprice._replace( sources=[find_prices.PriceSource(yahoo, 'USDJPY', True)]), False) self.assertEqual(('JPY', 'USD'), (entry.currency, entry.amount.currency)) self.assertEqual(D('0.008'), entry.amount.number)
def test_fetch_price__normal(self): entry = price.fetch_price( self.dprice._replace(sources=[ find_prices.PriceSource(google, 'CURRENCY:USDJPY', False) ]), False) self.assertEqual(('JPY', 'USD'), (entry.currency, entry.amount.currency)) self.assertEqual(D('125.00'), entry.amount.number)