def test_decrease_stock_amount_success(self): vending_machine = VendingMachine() vending_machine.add_item_to_slot(1, Item('Coffee', 1.75, 6)) decreased, new_stock = vending_machine.decrease_stock(1, 4) self.assertTrue(decreased) self.assertEqual(2, new_stock) self.assertEqual(2, vending_machine.slot_items[1].stock)
def test_decrease_stock_amount_higher_than_current_stock(self): vending_machine = VendingMachine() vending_machine.add_item_to_slot(1, Item('Coffee', 1.75, 6)) decreased, new_stock = vending_machine.decrease_stock(1, 25) self.assertTrue(decreased) self.assertEqual(0, new_stock) self.assertEqual(0, vending_machine.slot_items[1].stock)