def test_switch_on__if_timeout_is_out_of_range__should_raise_error( self, timeout): sdk = Mock() obj = Relay(sdk, RelayGroup.lock, 2) with pytest.raises(ValueError): obj.switch_on(timeout)
def test_eq__should_return_comparing_result(self, number, group): sdk = Mock() obj = Relay(sdk, RelayGroup.lock, 2) other_obj = Relay(sdk, group, number) expect = obj.number == other_obj.number and obj.group == other_obj.group assert obj.__eq__(other_obj) == expect
def test_relays__should_return_relays_object(self): res = self.obj.relays assert type(res) == RelayList assert res == (Relay(self.sdk, RelayGroup.lock, 1), Relay(self.sdk, RelayGroup.aux, 1), Relay(self.sdk, RelayGroup.lock, 2), Relay(self.sdk, RelayGroup.aux, 2))
def setup(self): self.sdk = Mock() self.relays = ( Relay(self.sdk, RelayGroup.aux, 1), Relay(self.sdk, RelayGroup.aux, 2), Relay(self.sdk, RelayGroup.lock, 1), Relay(self.sdk, RelayGroup.lock, 2), ) self.obj = RelayList(self.sdk, self.relays)
def test_switch_on__should_call_sdk_method(self, group, number): sdk = Mock() obj = Relay(sdk, group, number) timeout = 45 obj.switch_on(timeout) sdk.control_device.assert_called_once_with( ControlOperation.output.value, number, group.value, timeout, 0)
def setup(self): self.sdk = Mock() self.event_log = EventLog(self.sdk, 4096) self.door_number = 2 self.relays = ( Relay(self.sdk, RelayGroup.lock, 1), Relay(self.sdk, RelayGroup.aux, 1), ) self.relay_list = RelayList(self.sdk, self.relays) self.reader = Reader(self.sdk, self.event_log, self.door_number) self.aux_input = AuxInput(self.sdk, self.event_log, self.door_number) self.parameters = DoorParameters(self.sdk, ZK200, self.door_number) self.obj = Door(self.sdk, self.event_log, self.door_number, self.relay_list, self.reader, self.aux_input, self.parameters)
def test_init__should_init_properties(self, group, number): sdk = Mock() obj = Relay(sdk, group, number) assert obj._sdk is sdk assert obj.group == group assert obj.number == number
def setup(self): self.sdk = Mock() self.event_log = EventLog(self.sdk, 4096) self.doors = (Door( self.sdk, self.event_log, 1, RelayList(self.sdk, (Relay(self.sdk, RelayGroup.lock, 1), Relay(self.sdk, RelayGroup.aux, 1))), Reader(self.sdk, self.event_log, 1), AuxInput(self.sdk, self.event_log, 1), DoorParameters(self.sdk, ZK200, 1)), Door( self.sdk, self.event_log, 2, RelayList(self.sdk, (Relay(self.sdk, RelayGroup.lock, 2), Relay(self.sdk, RelayGroup.aux, 2))), Reader(self.sdk, self.event_log, 2), AuxInput(self.sdk, self.event_log, 2), DoorParameters(self.sdk, ZK200, 2))) self.obj = DoorList(self.sdk, self.event_log, self.doors)
def test_repr__should_return_name_of_class(self): sdk = Mock() obj = Relay(sdk, RelayGroup.lock, 2) assert repr(obj).startswith('Relay(')
def test_ne__if_other_object_type__should_return_true(self, val): sdk = Mock() obj = Relay(sdk, RelayGroup.lock, 2) assert obj.__ne__(val) is True