Ejemplo n.º 1
0
    def test_total_sum_of_bills(self):
        bills = [Bill(5), Bill(10), Bill(15)]
        batch = BatchBill(bills)

        expected_sum = 30

        self.assertEqual(batch.total(), expected_sum)
Ejemplo n.º 2
0
    def test_total_function(self):
        values = [10, 20, 50, 100]
        bills = [Bill(value) for value in values]
        batch = BatchBill(bills)
        result = batch.total()

        self.assertEqual(result, 180)
Ejemplo n.º 3
0
    def test_total_sum_of_bills_when_no_bills(self):
        bills = []
        batchBill = BatchBill(bills)

        expected_sum = 0

        self.assertEqual(batchBill.total(), expected_sum)
Ejemplo n.º 4
0
    def test_string_representation(self):
        values = [10, 20, 50, 100]
        bills = [Bill(value) for value in values]
        batch = BatchBill(bills)
        result = len(batch)

        self.assertEqual(result, 4)
Ejemplo n.º 5
0
	def test_when_bills_are_unordered(self):
		batch = BatchBill([Bill(25), Bill(10), Bill(15), Bill(10)])
		desk = CashDesk()	
		desk.take_money(batch)
		expected = '10$ bills: 2\n15$ bills: 1\n25$ bills: 1\n'
		
		self.assertEqual(str(desk), expected)
Ejemplo n.º 6
0
class TestBatchBill(unittest.TestCase):
    def setUp(self):
        values = [10, 20, 50, 100]
        self.bills = [Bill(value) for value in values]
        self.batch_bill = BatchBill(list_of_bills=self.bills)

    def test___init___method_with_non_Bill_instance_in_list_of_bills(self):
        with self.assertRaises(TypeError):
            BatchBill([Bill(10), Bill(15), 'abc'])

    def test___init___method(self):
        self.assertEqual(self.batch_bill.bills,
                         [Bill(10), Bill(20),
                          Bill(50), Bill(100)])
        self.bills[0] = Bill(50)
        self.assertEqual(self.batch_bill.bills,
                         [Bill(10), Bill(20),
                          Bill(50), Bill(100)])

    def test___len___method(self):
        self.assertEqual(len(self.batch_bill), 4)

    def test_total_method(self):
        self.assertEqual(self.batch_bill.total(), 180)

    def test___getitem___method(self):
        _sum = 0
        for bill in self.batch_bill:
            _sum += int(bill)
        self.assertEqual(self.batch_bill[1], Bill(20))
        self.assertEqual(_sum, 180)
Ejemplo n.º 7
0
    def test_index_of_some_Bill_in_BatchBill(self):
        values = [10, 20, 50, 100]
        bills = [Bill(value) for value in values]
        batch = BatchBill(bills)
        index = 3
        result = batch[index]

        self.assertEqual(result, Bill(100))
Ejemplo n.º 8
0
	def test_take_batch(self):
		batch = BatchBill([Bill(5), Bill(10), Bill(15)])
		desk = CashDesk()
		expected_dict = {Bill(5): 1, Bill(10): 1, Bill(15): 1}

		desk.take_money(batch)

		self.assertEqual(desk.get_dict(), expected_dict)
 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)
Ejemplo n.º 10
0
    def test_len_of_batch(self):
        bills = [Bill(5), Bill(10), Bill(15)]

        batchBill = BatchBill(bills)

        expected_len = 3

        self.assertEqual(len(batchBill), expected_len)
Ejemplo n.º 11
0
	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)
Ejemplo n.º 12
0
 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')
Ejemplo n.º 13
0
 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)])
Ejemplo n.º 14
0
    def test_iterable(self):
        values = [10, 20]
        bills = [Bill(value) for value in values]
        batch = BatchBill(bills)

        expected_result = 'A 10$ bill. A 20$ bill. '

        result = ''
        for bill in batch:
            result += str(bill) + '. '

        self.assertEqual(result, expected_result)
Ejemplo n.º 15
0
 def setUp(self):
     values = [10, 20, 50, 100]
     self.bills = [Bill(value) for value in values]
     self.batch_bill = BatchBill(list_of_bills=self.bills)
Ejemplo n.º 16
0
 def test___init___method_with_non_Bill_instance_in_list_of_bills(self):
     with self.assertRaises(TypeError):
         BatchBill([Bill(10), Bill(15), 'abc'])