Beispiel #1
0
 def test_fetch_price__naive_time_no_timeozne(self, fetch_cached):
     fetch_cached.return_value = SourcePrice(
         Decimal('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)
Beispiel #2
0
 def test_fetch_price__swapped(self):
     entry = price.fetch_price(
         self.dprice._replace(
             sources=[price.PriceSource(yahoo, 'USDJPY', True)]), True)
     self.assertEqual(('USD', 'JPY'),
                      (entry.currency, entry.amount.currency))
     self.assertEqual(Decimal('125.00'), entry.amount.number)
Beispiel #3
0
 def test_fetch_price__inverted(self):
     entry = price.fetch_price(
         self.dprice._replace(
             sources=[price.PriceSource(yahoo, 'USDJPY', True)]), False)
     self.assertEqual(('JPY', 'USD'),
                      (entry.currency, entry.amount.currency))
     self.assertEqual(Decimal('0.008'), entry.amount.number)
Beispiel #4
0
 def test_expressions(self):
     with test_utils.capture('stderr'):
         args, jobs, _, __ = run_with_args(
             price.process_args, ['--no-cache', '-e', 'USD:yahoo/AAPL'])
         self.assertEqual(
             [price.DatedPrice(
                 'AAPL', 'USD', None,
                 [price.PriceSource(yahoo, 'AAPL', False)])], jobs)