def test_relay_error_3_1(self, door_controller, relay_error_factory): from hocuspocus.main import display_error_code relay_error = relay_error_factory('3 1', 3, 1, "Mock Message") loop = cycle((True, False)) display_error_code(relay_error, door_controller, loop=loop) call_list = door_controller.mock_calls expected_calls = [ call.activate_pin(door_controller.red_pin, ms=2000, suffix_ms=2000), call.activate_pin( door_controller.red_pin, ms=1000, ), call.activate_pin( door_controller.red_pin, ms=1000, ), call.activate_pin(door_controller.red_pin, ms=1000, suffix_ms=2000), call.activate_pin(door_controller.red_pin, ms=1000, suffix_ms=2000), ] assert expected_calls == call_list
def test_door_is_held_open_for_the_given_seconds(self, door_controller, relay_error_generator): from hocuspocus.main import unlock_door self.check_relays.side_effect = relay_error_generator([ ('0 1', 0, 1, "Mock Message"), ]) assert unlock_door(door_controller, ms=10000) is None call_list = door_controller.mock_calls assert call_list == [ call.relays(activate=True), call.activate_pin(door_controller.green_pin, ms=5000), call.relays(activate=False), ]
def test_relays_are_deactivated_after_green_led_is_shown( self, door_controller, relay_error_generator): from hocuspocus.main import unlock_door self.check_relays.side_effect = relay_error_generator([ ('0 1', 0, 1, "Mock Message"), ]) assert unlock_door(door_controller, ms=10000) is None call_list = door_controller.mock_calls assert call_list == [ call.relays(activate=True), call.activate_pin(door_controller.green_pin, ms=5000), call.relays(activate=False), ]
def test_on_failure_try_to_recover_on_third_check(self, door_controller, relay_error_generator): from hocuspocus.main import unlock_door self.check_relays.side_effect = relay_error_generator([ ('0 1', 0, 1, "Mock Message"), ('0 1', 0, 1, "Mock Message"), ('2 3', 2, 3, "Mock Message"), ]) relay_error = unlock_door(door_controller) assert relay_error.codes.relay == 2 assert relay_error.codes.test == 3 call_list = door_controller.mock_calls assert call_list == [ call.relays(activate=True), call.activate_pin(door_controller.green_pin, ms=5000), call.relays(activate=False), call.relays(activate=False), ]