class TestCashDesk(unittest.TestCase): def setUp(self): self.bill = Bill(10) self.cash_desk = CashDesk() self.cash_desk.money = [Bill(5), Bill(20)] def test_take_money_method_with_a_Bill(self): self.cash_desk.take_money(self.bill) self.assertEqual(self.cash_desk.money, [Bill(5), Bill(20), Bill(10)]) def test_take_money_method_with_a_Batch_of_Bills(self): values = [10, 20, 50] bills = [Bill(value) for value in values] batch = BatchBill(bills) self.cash_desk.take_money(batch) self.assertEqual( self.cash_desk.money, [Bill(5), Bill(20), Bill(10), Bill(20), Bill(50)]) def test_take_money_method_with_invalid_argument(self): with self.assertRaises(TypeError): self.cash_desk.take_money('not Bill or BatchBill') def test_total_method_without_any_money(self): desk = CashDesk() self.assertEqual(desk.total(), 0) def test_total_method_with_money(self): self.assertEqual(self.cash_desk.total(), 25) self.cash_desk.take_money(Bill(100)) self.assertEqual(self.cash_desk.total(), 125) def test___str___method_with_not_any_money(self): self.assertEqual(str(CashDesk()), '') def test___str___method_with_one_Bill(self): desk = CashDesk() desk.take_money(Bill(100)) self.assertEqual(str(desk), '100$ bills - 1\n') def test___str___method(self): self.cash_desk.take_money(BatchBill([Bill(10), Bill(10), Bill(5)])) self.assertEqual(str(self.cash_desk), '5$ bills - 2\n' '10$ bills - 2\n' '20$ bills - 1\n') self.cash_desk.take_money(Bill(20)) self.cash_desk.take_money(Bill(10)) self.assertEqual(str(self.cash_desk), '5$ bills - 2\n' '10$ bills - 3\n' '20$ bills - 2\n')
def test_total_money_when_desk_is_empty(self): desk = CashDesk() expected = 0 result = desk.total() self.assertEqual(result, expected)
def test_take_money_function_by_using_total_batch_test(self): values = [10, 20, 50, 100] bills = [Bill(value) for value in values] batch = BatchBill(bills) desk = CashDesk() desk.take_money(batch) result = desk.total() self.assertEqual(result, 180)
def test_total_money(self): batch = BatchBill([Bill(5), Bill(10), Bill(15), Bill(10)]) desk = CashDesk() desk.take_money(batch) expected = 40 result = desk.total() self.assertEqual(result, expected)
def test_total_method_without_any_money(self): desk = CashDesk() self.assertEqual(desk.total(), 0)
def test_total_zero_when_new_instance_made(self): new_cash_desk = CashDesk() self.assertEqual(0, new_cash_desk.total())
def test_total_after_money_take(self): new_cash_desk = CashDesk() new_cash_desk.take_money({1: 2, 100: 3}) self.assertEqual(302, new_cash_desk.total())
def test_total_fuction(self): desk = CashDesk() result = desk.total() self.assertEqual(result, 0)
def test_take_money_function_by_using_total_bill_only_test(self): bill = Bill(10) desk = CashDesk() desk.take_money(bill) result = desk.total() self.assertEqual(result, 10)