def test_that_switch_pv_value_equals_switch_state_value_when_disabled( self): raw_value = self.device.switchstates['disable'] create_method_patch(self, EpicsDeviceThatHasDisablePv, '_get_pv', return_value_wrapper(raw_value)) assert self.device._get_pv('switchpv:read') == raw_value assert not self.device.isEnabled
def test_enable_sets_switchpv_write_if_not_enabled(self): disable_value = self.device.switchstates['disable'] enable_value = self.device.switchstates['enable'] create_method_patch(self, EpicsDeviceThatHasDisablePv, 'isEnabled', disable_value) with patch.object(EpicsDeviceThatHasDisablePv, '_put_pv') as \ mock_put_pv: self.device.enable() mock_put_pv.assert_called_once_with('switchpv:write', enable_value)
def test_is_enabled_raise_exception_if_different_from_switchstates(self): raw_value = 'on' disable_value = self.device.switchstates['disable'] enable_value = self.device.switchstates['enable'] assert not raw_value in [disable_value, enable_value] create_method_patch(self, EpicsDeviceThatHasDisablePv, '_get_pv', return_value_wrapper(raw_value)) with self.assertRaises(Exception) as context: assert self.device._get_pv('switchpv:read') == raw_value assert not self.device.isEnabled in [disable_value, enable_value] assert isinstance(context.exception, ConfigurationError)
def test_disable_does_nothing_if_already_disabled(self): raw_value = self.device.switchstates['disable'] create_method_patch(self, EpicsDeviceThatHasDisablePv, 'isEnabled', raw_value) self.device.disable() assert not self.mock.mock_calls