Exemplo n.º 1
0
 def test_currency_exchange_sum_list(self):
     self.assertEqual(CurrencyExchangeManager.sum([Currency.us_dollars(2, 3),
                                                   Currency.us_dollars(3, 5),
                                                   Currency.russian_roubles(60)], 'USD'), Currency.us_dollars(7,
         CurrencyExchangeManager.exchange_rates['USD']))
     self.assertEqual(CurrencyExchangeManager.sum([Currency.us_dollars(2, 3),
                                                   Currency.us_dollars(3, 5),
                                                   Currency.russian_roubles(60)]), Currency.russian_roubles(210))
     self.assertEqual(CurrencyExchangeManager.sum([Currency.us_dollars(2, 3),
                                                   Currency.us_dollars(3, 5),
                                                   Currency.russian_roubles(60),
                                                   Currency.euro(4, 90)], 'EUR'), Currency.euro(Decimal('8.66666666666666667'),
                                                                                                CurrencyExchangeManager.exchange_rates['EUR']))
Exemplo n.º 2
0
    def test_currency_ranges(self):
        Currency.russian_roubles("9999999999.99123459")
        self.assertRaises(MaxCurrencyException, Currency.russian_roubles, "19999999999.99123459")

        self.assertEqual(Currency.russian_roubles("9999999999.99123459").db_value(), 999999999999123459)
        self.assertEqual(Currency.russian_roubles("9999999999.99123459123").db_value(), 999999999999123459)

        self.assertEqual(Currency.euro("999999999.991234591", 10).db_value(), 999999999991234591)
        self.assertEqual(Currency.us_dollars("9111111.991234591", 1058).db_value(), 963955648672619728)
        self.assertEqual(Currency.us_dollars("9111111.991234591123123123", 1058).db_value(), 963955648672619741)

        self.assertEqual(Currency.euro("0.000000000001", 120).db_value(), 0)
        self.assertEqual(Currency.euro("0.0000000001", 100).db_value(), 1)
Exemplo n.º 3
0
 def test_currency_exchange_sum_list(self):
     self.assertEqual(
         CurrencyExchangeManager.sum([
             Currency.us_dollars(2, 3),
             Currency.us_dollars(3, 5),
             Currency.russian_roubles(60)
         ], 'USD'),
         Currency.us_dollars(7,
                             CurrencyExchangeManager.exchange_rates['USD']))
     self.assertEqual(
         CurrencyExchangeManager.sum([
             Currency.us_dollars(2, 3),
             Currency.us_dollars(3, 5),
             Currency.russian_roubles(60)
         ]), Currency.russian_roubles(210))
     self.assertEqual(
         CurrencyExchangeManager.sum([
             Currency.us_dollars(2, 3),
             Currency.us_dollars(3, 5),
             Currency.russian_roubles(60),
             Currency.euro(4, 90)
         ], 'EUR'),
         Currency.euro(Decimal('8.66666666666666667'),
                       CurrencyExchangeManager.exchange_rates['EUR']))