def test_mixed_addition(self): five_bucks = Money.dollar(5) ten_francs = Money.franc(10) bank = Bank() bank.add_rate('CHF', 'USD', 2) result = bank.reduce(five_bucks.plus(ten_francs), 'USD') self.assertEqual(result, Money.dollar(10))
def test_sum_times(self): five_bucks = Money.dollar(5) ten_francs = Money.franc(10) bank = Bank() bank.add_rate('CHF', 'USD', 2) sum = Sum(five_bucks, ten_francs).times(2) result = bank.reduce(sum, 'USD') self.assertEqual(result, Money.dollar(20))
def test_identity_rate(self): self.assertEqual(1, Bank().rate('USD', 'USD'))
def test_reduce_money_different_currency(self): bank = Bank() bank.add_rate('CHF', 'USD', 2) result = bank.reduce(Money.franc(2), 'USD') self.assertEqual(Money.dollar(1), result)
def test_reduce_money(self): bank = Bank() result = bank.reduce(Money.dollar(1), 'USD') self.assertEqual(Money.dollar(1), result)
def test_reduce_sum(self): sum = Sum(Money.dollar(3), Money.dollar(4)) bank = Bank() result = bank.reduce(sum, 'USD') self.assertEqual(Money.dollar(7), result)
def test_simple_addition(self): five = Money.dollar(5) sum = five.plus(five) bank = Bank() reduced = bank.reduce(sum, "USD") self.assertEqual(Money.dollar(10), reduced)