Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def test_expressions(self):
     with test_utils.capture('stderr'):
         args, jobs, _, __ = test_utils.run_with_args(
             price.process_args, ['--no-cache', '-e', 'USD:yahoo/AAPL'])
         self.assertEqual([
             find_prices.DatedPrice(
                 'AAPL', 'USD', None,
                 [find_prices.PriceSource(yahoo, 'AAPL', False)])
         ], jobs)
Exemplo n.º 5
0
 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 = find_prices.DatedPrice('JPY', 'USD',
                                     datetime.date(2015, 11, 22), None)
     with self.assertRaises(ValueError):
         price.fetch_price(
             dprice._replace(
                 sources=[find_prices.PriceSource(yahoo, 'USDJPY', False)]),
             False)