def test_money(): assert Money(7).amount == Money(5).plus(2) assert Money(8).amount == Money(5).plus(3)
def test_simples(): assert Money(10).amount == Bank().reduced(Money(Money(5).plus(5)))
def test_franc_to_dollar(): assert Money(50).amount == Bank().source_to_destiny(Franc(50), 'CHF') assert Money(5).amount == Bank().source_to_destiny(Franc(10), 'USD') assert Money(68.665).amount == Bank().source_to_destiny(Franc(137.33), 'USD')
def test_exchange_rate(): assert Money(5).amount == Bank().exchange_rate(Franc(10)) assert Money(68.665).amount == Bank().exchange_rate(Franc(137.33)) assert Money(10).amount == Bank().exchange_rate(Dollar(10))
def test_dollar_to_franc(): assert Money(20).amount == Bank().source_to_destiny(Dollar(10), 'CHF') assert Money(137.33).amount == Bank().source_to_destiny(Dollar(68.665), 'CHF') assert Money(68.665).amount == Bank().source_to_destiny(Dollar(68.665), 'USD')
def test_money(self): self.assertEqual(Money(10).amount, Money(5).times(2)) self.assertEqual(Money(15).amount, Money(5).times(3))
def test_inter(self): self.assertFalse(Dollar(10).equals_currency(Franc(10))) self.assertFalse(Dollar(10).equals_currency(Franc(15))) self.assertFalse(Money(10).equals_currency(Franc(10))) self.assertFalse(Money(10).equals_currency(Franc(15)))
def test_money(self): assert Money(10).equals_currency(Money(10)) assert Money(10).equals_currency(Money(15))
def test_money(self): assert Money(4).equals(Money(4)) assert Money(5).equals(Money(5)) self.assertFalse(Money(5).equals(Money(4))) self.assertFalse(Money(5).equals(Money(6)))