Ejemplo n.º 1
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 = 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)
Ejemplo n.º 2
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(
             [price.DatedPrice(
                 'AAPL', 'USD', None,
                 [price.PriceSource(yahoo, 'AAPL', False)])], jobs)
Ejemplo n.º 3
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(D('125.00'), entry.amount.number)
Ejemplo n.º 4
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(D('0.008'), entry.amount.number)