Esempio n. 1
0
    def test_showing_total_amount_in_batch(self):
        values = [1, 2, 5, 10]
        bills = [Bill(value) for value in values]

        batch = BatchBill(bills)

        result = batch.total()
        expected = 18

        self.assertEqual(result, expected)
class TestBatchBill(unittest.TestCase):
    def setUp(self):
        self.batch = BatchBill([Bill(50), Bill(10), Bill(30), Bill(20)])

    def test_getitem(self):
        self.assertEqual(self.batch[0], Bill(50))
        self.assertRaises(IndexError, self.batch.__getitem__, 5)

    def test_total(self):
        self.assertEqual(self.batch.total(), 110)
class TestBatchBill(unittest.TestCase):
    def setUp(self):
        self.list_values = [10, 20, 30]
        self.bill = [Bill(value) for value in self.list_values]
        self.Bbill = BatchBill(self.bill)

    def test_len(self):
        self.assertEqual(self.Bbill.__len__(), 3)

    def test_total(self):
        self.assertEqual(self.Bbill.total(), 60)
class TestBatchBill(unittest.TestCase):
    def setUp(self):
        self.bill5 = Bill(5)
        self.bill10 = Bill(10)
        self.batch = BatchBill([self.bill5, self.bill10])

    def test_batchbill_init(self):
        self.assertIn(self.bill5, self.batch)
        self.assertIn(self.bill10, self.batch)

    def test_batchbill_total(self):
        self.assertEqual(self.batch.total(), 15)
Esempio n. 5
0
    def test_total(self):
        e = None

        try:
            billList = [Bill(value) for value in range(1, 5)]
            batch = BatchBill(billList)
            res = batch.total()
        except Exception as exc:
            e = exc

        print(res)
        self.assertIsNone(e)
        self.assertEqual(10, res)
class CashDeskTest(unittest.TestCase):

    def setUp(self):
        self.bill = Bill(10)
        self.batch = BatchBill([Bill(5), Bill(10), Bill(15)])
        self.desk = CashDesk()

    def test_type_of_amount(self):
        with self.assertRaises(TypeError):
            Bill("10")

    def test_value_of_amount(self):
        with self.assertRaises(ValueError):
            Bill(-5)

    def test_batchbill_total(self):
        self.assertEqual(self.batch.total(), 30)

    def test_take_money_from_bill(self):
        self.desk.take_money(self.bill)
        self.assertEqual(self.desk.gold, 10)

    def test_take_money_from_batch(self):
        self.desk.take_money(self.batch)
        self.assertEqual(self.desk.gold, 30)

    def test_cashdesk_total(self):
        self.desk.take_money(self.bill)
        self.desk.take_money(self.batch)
        self.assertEqual(
            self.desk.total(), 'We have a total of 40$ in the bank')

    def test_cashdesk_inspect_value(self):
        self.desk.take_money(self.bill)
        self.desk.take_money(self.batch)
        self.desk.inspect()
Esempio n. 7
0
 def test_total_more_elements(self):
     b = BatchBill([Bill(30),Bill(10),Bill(10),Bill(23),Bill(110),Bill(15)])
     res = b.total()
     self.assertEqual(res, 198)
Esempio n. 8
0
 def test_total_three_elements(self):
     b = BatchBill([Bill(30),Bill(10),Bill(10)])
     res = b.total()
     self.assertEqual(res, 50)
Esempio n. 9
0
 def test_total_one_element(self):
     b = BatchBill([Bill(30)])
     res = b.total()
     self.assertEqual(res, 30)