Exemple #1
0
    def test_remove_money_success(self):
        vending_machine = VendingMachine()
        vending_machine.insert_money(238)
        removed, total_balance = vending_machine.remove_money(213)

        self.assertTrue(removed)
        self.assertEqual(25, total_balance)
Exemple #2
0
    def test_insert_money_success(self):
        vending_machine = VendingMachine()
        inserted, total_balance = vending_machine.insert_money(12)

        self.assertTrue(inserted)
        self.assertEqual(12, total_balance)

        inserted, total_balance = vending_machine.insert_money(53.5)

        self.assertTrue(inserted)
        self.assertEqual(65.5, total_balance)
Exemple #3
0
    def test_select_and_vend_out_of_stock(self):
        orange_juice = Item('Orange Juice', 1.50, 0)

        vending_machine = VendingMachine()
        vending_machine.add_item_to_slot(1, orange_juice)
        vending_machine.insert_money(12)
        vended, item_summary, vend_result, total_balance = vending_machine.select_and_vend(
            1)

        self.assertFalse(vended)
        self.assertEqual('Orange Juice', item_summary)
        self.assertEqual('Out of Stock', vend_result)
Exemple #4
0
    def test_select_and_vend_success(self):
        soda = Item('Soda', 1.25, 20)

        vending_machine = VendingMachine()
        vending_machine.insert_money(10.0)
        vending_machine.add_item_to_slot(3, soda)
        vended, item_summary, vend_result, total_balance = vending_machine.select_and_vend(
            3)

        self.assertTrue(vended)
        self.assertEqual('Soda', item_summary)
        self.assertEqual('Vended: Soda', vend_result)
        self.assertEqual(8.75, total_balance)
Exemple #5
0
    def test_remove_money_amount_higher_than_balance(self):
        vending_machine = VendingMachine()
        inserted, total_balance = vending_machine.insert_money(23)
        removed, total_balance_after_removal = vending_machine.remove_money(
            total_balance * 2)

        self.assertTrue(removed)
        self.assertEqual(0, total_balance_after_removal)
Exemple #6
0
 def test_check_purchace(self):
     vm = VendingMachine()
     name = 'コーラ'
     vm.insert_money(10)
     assert vm.check_purchace(name) == False
     vm = VendingMachine()
     name = 'スプライト'
     vm.insert_money(10)
     assert vm.check_purchace(name) == False
     vm = VendingMachine()
     name = 'スプライト'
     vm.insert_money(500)
     assert vm.check_purchace(name) == False
     vm = VendingMachine()
     name = 'コーラ'
     vm.insert_money(500)
     assert vm.check_purchace(name) == True
Exemple #7
0
    def test_insert_money_negative_amount(self):
        vending_machine = VendingMachine()
        inserted, total_balance = vending_machine.insert_money(-21.65)

        self.assertFalse(inserted)
        self.assertEqual(0, total_balance)
 def test_insert_money(self):
     vm = VendingMachine()
     vm.insert_money(10)
     vm.insert_money(1)
     assert vm.total_money_amount == 10
 def test_refund_money(self):
     vm = VendingMachine()
     vm.insert_money(10)
     vm.insert_money(500)
     vm.insert_money(1000)
     assert vm.refund_money() == 1510
 def test_get_total_money_amount(self):
     vm = VendingMachine()
     vm.insert_money(10)
     vm.insert_money(500)
     vm.insert_money(1000)
     assert vm.get_total_money_amount() == 1510