Ejemplo n.º 1
0
 def test_exchange_amount(self):
     five_dollars = Bank.exchange(Money(5, "USD"))
     self.assertEqual(Money(5, "USD"), five_dollars)
     ten_francs = Bank.exchange(Money(10, "CHF"))
     self.assertEqual(Money(5, "USD"), ten_francs)
     eleven_francs = Bank.exchange(Money(11, "CHF"))
     self.assertEqual(Money(5.5, "USD"), eleven_francs)
def test_reduce_money_different_currency():

    bank = Bank()
    bank.add_rate("CHF", "USD", 2)
    result = bank.exchange(Money.francs(2), "USD")

    assert Money.dollar(1) == result
def test_simple_addition():

    five = Money.dollar(5)
    money_sum = five + five
    bank = Bank()
    reduced = bank.exchange(money_sum, "USD")
    assert Money.dollar(10) == reduced
def test_mixed_addition():

    five_bucks = Money.dollar(5)
    ten_francs = Money.francs(10)

    bank = Bank()
    bank.add_rate("CHF", "USD", 2)

    result = five_bucks + bank.exchange(ten_francs, "USD")

    assert result == Money.dollar(10)