Example #1
0
 def test_mixed_addition(self):
     five_bucks = Money.dollar(5)
     ten_franc = Money.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(five_bucks.plus(ten_franc), 'USD')
     assert Money.dollar(10) == result
Example #2
0
 def test_mixed_addition(self, money):
     five_bucks = money.dollar(5)
     ten_francs = money.franc(10)
     bank = Bank()
     bank.addRate("CHF", "USD", 2)
     result = bank.reduce(five_bucks.plus(ten_francs), "USD")
     assert money.dollar(10) == result
Example #3
0
 def test_simple_addition(self):
     """同一単位の加算"""
     five = Money.dollar(5)
     total = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(total, "USD")
     self.assertEqual(Money.dollar(10), reduced, "equal")
Example #4
0
 def test_mix_ed_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(Money.dollar(10), result)
Example #5
0
 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(Money.dollar(20), result)
Example #6
0
 def test_TotalTimes(self, money):
     five_bucks = money.dollar(5)
     ten_francs = money.franc(10)
     bank = Bank()
     bank.addRate("CHF", "USD", 2)
     summation = Summation(five_bucks, ten_francs).times(2)
     result = bank.reduce(summation, "USD")
     assert money.dollar(20) == result
Example #7
0
 def test_sum_times(self):
     five_bucks = Money.dollar(5)
     ten_franc = Money.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     total = Total(five_bucks, ten_franc).times(2)
     result = bank.reduce(total, 'USD')
     assert Money.dollar(20) == result
    def test_SimpleAddition(self):
        assert Money.dollar(5).plus(Money.dollar(5)) == Money.dollar(10)

        five = Money.dollar(5)
        sumattion = five.plus(five)
        bank = Bank()
        reduced = bank.reduce(sumattion, "USD")
        assert Money.dollar(10) == reduced
Example #9
0
 def test_sum_plus_money(self):
     five_bucks = Money.dollar(5)
     ten_franc = Money.franc(10)
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     total = Total(five_bucks, ten_franc).plus(five_bucks)
     result = bank.reduce(total, 'USD')
     assert Money.dollar(15) == result
Example #10
0
 def test_totalplus_money(self):
     """合計の加算"""
     five_bucks = Money.dollar(5)
     ten_francs = Money.franc(10)
     bank = Bank()
     bank.add_rate("CHF", "USD", 2)
     total = Total(five_bucks, ten_francs).plus(five_bucks)
     result = bank.reduce(total, "USD")
     self.assertEqual(Money.dollar(15), result)
Example #11
0
 def test_total_times(self):
     """moneyの倍"""
     five_bucks = Money.dollar(5)
     ten_francs = Money.franc(10)
     bank = Bank()
     bank.add_rate("CHF", "USD", 2)
     total = Total(five_bucks, ten_francs).times(2)
     result = bank.reduce(total, "USD")
     self.assertEqual(Money.dollar(20), result)
Example #12
0
 def test_ReduceSum(self):
     summation = Summation(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(summation, "USD")
     assert result == Money.dollar(7)
Example #13
0
 def test_rate_notfound(self):
     """変換レートが存在しない"""
     bank = Bank()
     with self.assertRaises(KeyError):
         bank.rate("USD", "FRN")
Example #14
0
 def test_identity_rate(self):
     """同一貨幣"""
     self.assertEqual(1, Bank().rate("USD", "USD"))
Example #15
0
 def test_reducemoney_diff_currency(self):
     """別の貨幣へ変換"""
     bank = Bank()
     bank.add_rate("CHF", "USD", 2)
     result = bank.reduce(Money.franc(2), "USD")
     self.assertEqual(Money.dollar(1), result)
Example #16
0
 def test_reduce_money(self):
     """Moneyのテスト"""
     bank = Bank()
     result = bank.reduce(Money.dollar(1), "USD")
     self.assertEqual(Money.dollar(1), result, "Money as expression")
Example #17
0
 def test_reducesum(self):
     """合計のテスト"""
     total = Total(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(total, "USD")
     self.assertEqual(Money.dollar(7), result)
Example #18
0
 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)
Example #19
0
 def test_simple_addition(self):
     five = Money.dollar(5)
     total = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(total, 'USD')
     assert Money.dollar(10) == reduced
Example #20
0
 def test_reduce_money_different_currency(self):
     bank = Bank()
     bank.add_rate('CHF', 'USD', 2)
     result = bank.reduce(Money.franc(2), 'USD')
     assert Money.dollar(1) == result
Example #21
0
 def test_reduce_sum(self):
     total = Total(Money.dollar(3), Money.dollar(4))
     bank = Bank()
     result = bank.reduce(total, "USD")
     assert Money.dollar(7) == result
Example #22
0
 def test_Reducemoney(self, money):
     bank = Bank()
     result = bank.reduce(money.dollar(1), "USD")
     assert money.dollar(1) == result
Example #23
0
 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)
Example #24
0
 def test_ReduceMoney(self):
     bank = Bank()
     result = bank.reduce(Money.dollar(1), "USD")
     assert Money.dollar(1) == result
Example #25
0
 def test_SimpleAddition(self, money):
     five = money.dollar(5)
     summation = five.plus(five)
     bank = Bank()
     reduced = bank.reduce(summation, "USD")
     assert money.dollar(10) == reduced
Example #26
0
 def test_ReduceMoneyDifferentCurrency(self):
     bank = Bank()
     bank.addRate("CHF", "USD", 2)
     result = bank.reduce(Money.franc(2), "USD")
     assert Money.dollar(1) == result
Example #27
0
 def test_reduce_money(self):
     bank = Bank()
     result = bank.reduce(Money.dollar(1), "USD")
     self.assertEqual(Money.dollar(1), result)