def test_two_undos(self, door_and_invoker): door, invoker = door_and_invoker invoker.activate(door) invoker.deactivate(door) for i in range(2): invoker.undo() assert not door.locked
def test_lots_of_undos(self, ninjas_and_invoker): ninjas, invoker = ninjas_and_invoker for i in range(30): invoker.activate(ninjas) invoker.deactivate(ninjas) for i in range(40): invoker.undo() assert not ninjas.armed
def test_door_unlock_and_lock(door_and_invoker): door, invoker = door_and_invoker door.lock() invoker.deactivate(door) invoker.activate(door) assert door.locked
def test_basic_door_unlock(door_and_invoker): door, invoker = door_and_invoker door.lock() invoker.deactivate(door) assert not door.locked
def test_off_undo(self, toaster_and_invoker): toaster, invoker = toaster_and_invoker toaster.on() invoker.deactivate(toaster) invoker.undo() assert toaster.is_on
def test_basic_security_disarm(ninjas_and_invoker): ninjas, invoker = ninjas_and_invoker ninjas.arm() invoker.deactivate(ninjas) assert not ninjas.armed
def test_basic_appliance_off(toaster_and_invoker): toaster, invoker = toaster_and_invoker toaster.on() invoker.deactivate(toaster) assert not toaster.is_on