def test_move_item_to_slot_empty_target_slot(self): vending_machine = VendingMachine() vending_machine.add_item_to_slot(1, Item('Soda', 1.25, 20)) self.assertTrue(vending_machine.move_item_to_slot(1, 2)) self.assertIsNone(vending_machine.slot_items[1]) self.assertEqual('Soda', vending_machine.slot_items[2].name)
def test_move_item_to_slot_replace_item_in_target_slot(self): vending_machine = VendingMachine() vending_machine.add_item_to_slot(1, Item('Soda', 1.25, 20)) vending_machine.add_item_to_slot(2, Item('Coffee', 1.75, 6)) self.assertTrue(vending_machine.move_item_to_slot(1, 2, replace=True)) self.assertIsNone(vending_machine.slot_items[1]) self.assertEqual('Soda', vending_machine.slot_items[2].name)
def test_move_item_to_slot_target_slot_has_item(self): vending_machine = VendingMachine() vending_machine.add_item_to_slot(1, Item('Soda', 1.25, 20)) vending_machine.add_item_to_slot(2, Item('Coffee', 1.75, 6)) self.assertFalse(vending_machine.move_item_to_slot(1, 2)) self.assertEqual('Soda', vending_machine.slot_items[1].name) self.assertEqual('Coffee', vending_machine.slot_items[2].name)