desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.handler_method = None
self.hass.bus.listen = mock.Mock()
|
'Clear data.'
| def tearDown(self):
| self.hass.stop()
|
'Test the setup with full configuration.'
| def test_setup_config_full(self, mock_client):
| config = {'influxdb': {'host': 'host', 'port': 123, 'database': 'db', 'username': 'user', 'password': 'password', 'ssl': 'False', 'verify_ssl': 'False'}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.assertTrue(self.hass.bus.listen.called)
self.assertEqual(EVENT_STATE_CHANGED, self.has... |
'Test the setup with default configuration.'
| def test_setup_config_defaults(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass'}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.assertTrue(self.hass.bus.listen.called)
self.assertEqual(EVENT_STATE_CHANGED, self.hass.bus.listen.call_args_list[0][0][0])
|
'Test the setup with minimal configuration.'
| def test_setup_minimal_config(self, mock_client):
| config = {'influxdb': {}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
|
'Test the setup with existing username and missing password.'
| def test_setup_missing_password(self, mock_client):
| config = {'influxdb': {'username': 'user'}}
assert (not setup_component(self.hass, influxdb.DOMAIN, config))
|
'Test the setup for query failures.'
| def test_setup_query_fail(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass'}}
mock_client.return_value.query.side_effect = influx_client.exceptions.InfluxDBClientError('fake')
assert (not setup_component(self.hass, influxdb.DOMAIN, config))
|
'Setup the client.'
| def _setup(self):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'exclude': {'entities': ['fake.blacklisted'], 'domains': ['another_fake']}}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
|
'Test the event listener.'
| def test_event_listener(self, mock_client):
| self._setup()
valid = {'1': 1, '1.0': 1.0, STATE_ON: 1, STATE_OFF: 0, 'foo': 'foo'}
for (in_, out) in valid.items():
attrs = {'unit_of_measurement': 'foobars', 'longitude': '1.1', 'latitude': '2.2', 'battery_level': '99%', 'temperature': '20c', 'last_seen': 'Last seen 23 minutes ago', 'u... |
'Test the event listener for missing units.'
| def test_event_listener_no_units(self, mock_client):
| self._setup()
for unit in (None, ''):
if unit:
attrs = {'unit_of_measurement': unit}
else:
attrs = {}
state = mock.MagicMock(state=1, domain='fake', entity_id='fake.entity-id', object_id='entity', attributes=attrs)
event = mock.MagicMock(data={'new_state':... |
'Test the event listener for write failures.'
| def test_event_listener_fail_write(self, mock_client):
| self._setup()
state = mock.MagicMock(state=1, domain='fake', entity_id='fake.entity-id', object_id='entity', attributes={})
event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
mock_client.return_value.write_points.side_effect = influx_client.exceptions.InfluxDBClientError('foo')
self... |
'Test the event listener against ignored states.'
| def test_event_listener_states(self, mock_client):
| self._setup()
for state_state in (1, 'unknown', '', 'unavailable'):
state = mock.MagicMock(state=state_state, domain='fake', entity_id='fake.entity-id', object_id='entity', attributes={})
event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
body = [{'measurement': 'fake.en... |
'Test the event listener against a blacklist.'
| def test_event_listener_blacklist(self, mock_client):
| self._setup()
for entity_id in ('ok', 'blacklisted'):
state = mock.MagicMock(state=1, domain='fake', entity_id='fake.{}'.format(entity_id), object_id=entity_id, attributes={})
event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
body = [{'measurement': 'fake.{}'.format(ent... |
'Test the event listener against a blacklist.'
| def test_event_listener_blacklist_domain(self, mock_client):
| self._setup()
for domain in ('ok', 'another_fake'):
state = mock.MagicMock(state=1, domain=domain, entity_id='{}.something'.format(domain), object_id='something', attributes={})
event = mock.MagicMock(data={'new_state': state}, time_fired=12345)
body = [{'measurement': '{}.something'.for... |
'Test the event listener against a whitelist.'
| def test_event_listener_whitelist(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'include': {'entities': ['fake.included']}}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
for entity_id in ('included', 'default'):
stat... |
'Test the event listener against a whitelist.'
| def test_event_listener_whitelist_domain(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'include': {'domains': ['fake']}}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
for domain in ('fake', 'another_fake'):
state = mock.Mag... |
'Test the event listener when an attribute has an invalid type.'
| def test_event_listener_invalid_type(self, mock_client):
| self._setup()
valid = {'1': 1, '1.0': 1.0, STATE_ON: 1, STATE_OFF: 0, 'foo': 'foo'}
for (in_, out) in valid.items():
attrs = {'unit_of_measurement': 'foobars', 'longitude': '1.1', 'latitude': '2.2', 'invalid_attribute': ['value1', 'value2']}
state = mock.MagicMock(state=in_, domain='fake', e... |
'Test the event listener with a default measurement.'
| def test_event_listener_default_measurement(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'default_measurement': 'state', 'exclude': {'entities': ['fake.blacklisted']}}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
for entity_id in ('... |
'Test the event listener when some attributes should be tags.'
| def test_event_listener_tags_attributes(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'tags_attributes': ['friendly_fake']}}
assert setup_component(self.hass, influxdb.DOMAIN, config)
self.handler_method = self.hass.bus.listen.call_args_list[0][0][1]
attrs = {'friendly_fake': 'tag_str', 'field_fake': 'field_st... |
'Test the event listener with overrided measurements.'
| def test_event_listener_component_override_measurement(self, mock_client):
| config = {'influxdb': {'host': 'host', 'username': 'user', 'password': 'pass', 'component_config': {'sensor.fake_humidity': {'override_measurement': 'humidity'}}, 'component_config_glob': {'binary_sensor.*motion': {'override_measurement': 'motion'}}, 'component_config_domain': {'climate': {'override_measurement': '... |
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test request config with least amount of data.'
| def test_request_least_info(self):
| request_id = configurator.request_config(self.hass, 'Test Request', (lambda _: None))
self.assertEqual(1, len(self.hass.services.services.get(configurator.DOMAIN, [])), 'No new service registered')
states = self.hass.states.all()
self.assertEqual(1, len(states), 'Expected a new stat... |
'Test request config with all possible info.'
| def test_request_all_info(self):
| exp_attr = {ATTR_FRIENDLY_NAME: 'Test Request', configurator.ATTR_DESCRIPTION: 'config description', configurator.ATTR_DESCRIPTION_IMAGE: 'config image url', configurator.ATTR_SUBMIT_CAPTION: 'config submit caption', configurator.ATTR_FIELDS: [], configurator.ATTR_LINK_NAME: 'link name', config... |
'Test if our callback gets called when configure service called.'
| def test_callback_called_on_configure(self):
| calls = []
request_id = configurator.request_config(self.hass, 'Test Request', (lambda _: calls.append(1)))
self.hass.services.call(configurator.DOMAIN, configurator.SERVICE_CONFIGURE, {configurator.ATTR_CONFIGURE_ID: request_id})
self.hass.block_till_done()
self.assertEqual(1, len(calls), 'Callb... |
'Test state change on notify errors.'
| def test_state_change_on_notify_errors(self):
| request_id = configurator.request_config(self.hass, 'Test Request', (lambda _: None))
error = 'Oh no bad bad bad'
configurator.notify_errors(request_id, error)
state = self.hass.states.all()[0]
self.assertEqual(error, state.attributes.get(configurator.ATTR_ERRORS))
|
'Test if notify errors fails silently with a bad request id.'
| def test_notify_errors_fail_silently_on_bad_request_id(self):
| configurator.notify_errors(2015, 'Try this error')
|
'Test if calling request done works.'
| def test_request_done_works(self):
| request_id = configurator.request_config(self.hass, 'Test Request', (lambda _: None))
configurator.request_done(request_id)
self.assertEqual(1, len(self.hass.states.all()))
self.hass.bus.fire(EVENT_TIME_CHANGED)
self.hass.block_till_done()
self.assertEqual(0, len(self.hass.states.all()))
|
'Test that request_done fails silently with a bad request id.'
| def test_request_done_fail_silently_on_bad_request_id(self):
| configurator.request_done(2016)
|
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
|
'Stop down everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test introduction setup.'
| def test_setup(self):
| self.assertTrue(setup_component(self.hass, introduction.DOMAIN, {}))
|
'Create new Mock Dyson State.'
| def __init__(self):
| pass
|
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test setup component with no devices.'
| def test_setup_component_with_no_devices(self):
| self.hass.data[dyson.DYSON_DEVICES] = []
add_devices = mock.MagicMock()
dyson.setup_platform(self.hass, None, add_devices)
add_devices.assert_called_with([])
|
'Test setup component with devices.'
| def test_setup_component(self):
| def _add_device(devices):
assert (len(devices) == 1)
assert (devices[0].name == 'Device_name')
device_fan = _get_device_on()
device_non_fan = _get_device_off()
self.hass.data[dyson.DYSON_DEVICES] = [device_fan, device_non_fan]
dyson.setup_platform(self.hass, None, _add_device)
|
'Test set fan speed.'
| def test_dyson_set_speed(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.set_speed('1')
set_config = device.set_configuration
set_config.assert_called_with(fan_mode=FanMode.FAN, fan_speed=FanSpeed.FAN_SPEED_1)
component.set_spee... |
'Test turn on fan.'
| def test_dyson_turn_on(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.turn_on()
set_config = device.set_configuration
set_config.assert_called_with(fan_mode=FanMode.FAN)
|
'Test turn on fan with night mode.'
| def test_dyson_turn_night_mode(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.night_mode(True)
set_config = device.set_configuration
set_config.assert_called_with(night_mode=NightMode.NIGHT_MODE_ON)
component.night_mode(False)
se... |
'Test night mode.'
| def test_is_night_mode(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.is_night_mode)
device = _get_device_off()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertTrue(component.is_night_mode)
|
'Test turn on/off fan with auto mode.'
| def test_dyson_turn_auto_mode(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.auto_mode(True)
set_config = device.set_configuration
set_config.assert_called_with(fan_mode=FanMode.AUTO)
component.auto_mode(False)
set_config = devi... |
'Test auto mode.'
| def test_is_auto_mode(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.is_auto_mode)
device = _get_device_auto()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertTrue(component.is_auto_mode)
|
'Test turn on fan with specified speed.'
| def test_dyson_turn_on_speed(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.turn_on('1')
set_config = device.set_configuration
set_config.assert_called_with(fan_mode=FanMode.FAN, fan_speed=FanSpeed.FAN_SPEED_1)
component.turn_on('A... |
'Test turn off fan.'
| def test_dyson_turn_off(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.should_poll)
component.turn_off()
set_config = device.set_configuration
set_config.assert_called_with(fan_mode=FanMode.OFF)
|
'Test turn off oscillation.'
| def test_dyson_oscillate_off(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
component.oscillate(False)
set_config = device.set_configuration
set_config.assert_called_with(oscillation=Oscillation.OSCILLATION_OFF)
|
'Test turn on oscillation.'
| def test_dyson_oscillate_on(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
component.oscillate(True)
set_config = device.set_configuration
set_config.assert_called_with(oscillation=Oscillation.OSCILLATION_ON)
|
'Test get oscillation value on.'
| def test_dyson_oscillate_value_on(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertTrue(component.oscillating)
|
'Test get oscillation value off.'
| def test_dyson_oscillate_value_off(self):
| device = _get_device_off()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.oscillating)
|
'Test device is on.'
| def test_dyson_on(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertTrue(component.is_on)
|
'Test device is off.'
| def test_dyson_off(self):
| device = _get_device_off()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.is_on)
device = _get_device_with_no_state()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertFalse(component.is_on)
|
'Test get device speed.'
| def test_dyson_get_speed(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertEqual(component.speed, 1)
device = _get_device_off()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertEqual(component.speed, 4)
device = _get_device_with_no_state()
co... |
'Test get device direction.'
| def test_dyson_get_direction(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertIsNone(component.current_direction)
|
'Test get speeds list.'
| def test_dyson_get_speed_list(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertEqual(len(component.speed_list), 11)
|
'Test supported features.'
| def test_dyson_supported_features(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
self.assertEqual(component.supported_features, 3)
|
'Test when message is received.'
| def test_on_message(self):
| device = _get_device_on()
component = dyson.DysonPureCoolLinkDevice(self.hass, device)
component.entity_id = 'entity_id'
component.schedule_update_ha_state = mock.Mock()
component.on_message(MockDysonState())
component.schedule_update_ha_state.assert_called_with()
|
'Test set night mode service.'
| def test_service_set_night_mode(self):
| dyson_device = mock.MagicMock()
self.hass.data[DYSON_DEVICES] = []
dyson_device.entity_id = 'fan.living_room'
self.hass.data[dyson.DYSON_FAN_DEVICES] = [dyson_device]
dyson.setup_platform(self.hass, None, mock.MagicMock())
self.hass.services.call(dyson.DOMAIN, dyson.SERVICE_SET_NIGHT_MODE, {'ent... |
'Initialize the fan.'
| def __init__(self):
| pass
|
'Set up test data.'
| def setUp(self):
| self.fan = BaseFan()
|
'Tear down unit test data.'
| def tearDown(self):
| self.fan = None
|
'Test fan entity methods.'
| def test_fanentity(self):
| self.assertIsNone(self.fan.state)
self.assertEqual(0, len(self.fan.speed_list))
self.assertEqual(0, self.fan.supported_features)
self.assertEqual({}, self.fan.state_attributes)
self.fan.set_speed()
self.fan.oscillate()
with self.assertRaises(NotImplementedError):
self.fan.turn_on()
... |
'Helper method to get the fan entity.'
| def get_entity(self):
| return self.hass.states.get(FAN_ENTITY_ID)
|
'Initialize unit test data.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.assertTrue(setup_component(self.hass, fan.DOMAIN, {'fan': {'platform': 'demo'}}))
self.hass.block_till_done()
|
'Tear down unit test data.'
| def tearDown(self):
| self.hass.stop()
|
'Test turning on the device.'
| def test_turn_on(self):
| self.assertEqual(STATE_OFF, self.get_entity().state)
fan.turn_on(self.hass, FAN_ENTITY_ID)
self.hass.block_till_done()
self.assertNotEqual(STATE_OFF, self.get_entity().state)
fan.turn_on(self.hass, FAN_ENTITY_ID, fan.SPEED_HIGH)
self.hass.block_till_done()
self.assertEqual(STATE_ON, self.get... |
'Test turning off the device.'
| def test_turn_off(self):
| self.assertEqual(STATE_OFF, self.get_entity().state)
fan.turn_on(self.hass, FAN_ENTITY_ID)
self.hass.block_till_done()
self.assertNotEqual(STATE_OFF, self.get_entity().state)
fan.turn_off(self.hass, FAN_ENTITY_ID)
self.hass.block_till_done()
self.assertEqual(STATE_OFF, self.get_entity().stat... |
'Test turning off all fans.'
| def test_turn_off_without_entity_id(self):
| self.assertEqual(STATE_OFF, self.get_entity().state)
fan.turn_on(self.hass, FAN_ENTITY_ID)
self.hass.block_till_done()
self.assertNotEqual(STATE_OFF, self.get_entity().state)
fan.turn_off(self.hass)
self.hass.block_till_done()
self.assertEqual(STATE_OFF, self.get_entity().state)
|
'Test setting the direction of the device.'
| def test_set_direction(self):
| self.assertEqual(STATE_OFF, self.get_entity().state)
fan.set_direction(self.hass, FAN_ENTITY_ID, fan.DIRECTION_REVERSE)
self.hass.block_till_done()
self.assertEqual(fan.DIRECTION_REVERSE, self.get_entity().attributes.get('direction'))
|
'Test setting the speed of the device.'
| def test_set_speed(self):
| self.assertEqual(STATE_OFF, self.get_entity().state)
fan.set_speed(self.hass, FAN_ENTITY_ID, fan.SPEED_LOW)
self.hass.block_till_done()
self.assertEqual(fan.SPEED_LOW, self.get_entity().attributes.get('speed'))
|
'Test oscillating the fan.'
| def test_oscillate(self):
| self.assertFalse(self.get_entity().attributes.get('oscillating'))
fan.oscillate(self.hass, FAN_ENTITY_ID, True)
self.hass.block_till_done()
self.assertTrue(self.get_entity().attributes.get('oscillating'))
fan.oscillate(self.hass, FAN_ENTITY_ID, False)
self.hass.block_till_done()
self.assertF... |
'Test is on service call.'
| def test_is_on(self):
| self.assertFalse(fan.is_on(self.hass, FAN_ENTITY_ID))
fan.turn_on(self.hass, FAN_ENTITY_ID)
self.hass.block_till_done()
self.assertTrue(fan.is_on(self.hass, FAN_ENTITY_ID))
|
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test if Dyson connection failed.'
| @mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=False)
def test_dyson_login_failed(self, mocked_login):
| dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR'}})
self.assertEqual(mocked_login.call_count, 1)
|
'Test valid connection to dyson web service.'
| @mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_login(self, mocked_login, mocked_devices):
| dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR'}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
self.assertEqual(len(self.hass.data[dyson.DYSON_DEVICES]), 0)
|
'Test device connection using custom configuration.'
| @mock.patch('homeassistant.helpers.discovery.load_platform')
@mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_custom_conf(self, mocked_login, mocked_devices, mocked_di... | dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_DEVICES: [{'device_id': 'XX-XXXXX-XX', 'device_ip': '192.168.0.1'}]}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
s... |
'Test device connection with an invalid device.'
| @mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_not_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_custom_conf_device_not_available(self, mocked_login, mocked_devices):
| dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_DEVICES: [{'device_id': 'XX-XXXXX-XX', 'device_ip': '192.168.0.1'}]}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
s... |
'Test device connection with device raising an exception.'
| @mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_error()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_custom_conf_device_error(self, mocked_login, mocked_devices):
| dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_DEVICES: [{'device_id': 'XX-XXXXX-XX', 'device_ip': '192.168.0.1'}]}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
s... |
'Test device connection with custom conf and unknown device.'
| @mock.patch('homeassistant.helpers.discovery.load_platform')
@mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_custom_conf_with_unknown_device(self, mocked_login, mocke... | dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_DEVICES: [{'device_id': 'XX-XXXXX-XY', 'device_ip': '192.168.0.1'}]}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
s... |
'Test device connection using discovery.'
| @mock.patch('homeassistant.helpers.discovery.load_platform')
@mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_discovery(self, mocked_login, mocked_devices, mocked_disc... | dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_TIMEOUT: 5, dyson.CONF_RETRY: 2}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
self.assertEqual(len(self.hass.data[d... |
'Test device connection with discovery and invalid device.'
| @mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_not_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_discovery_device_not_available(self, mocked_login, mocked_devices):
| dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_TIMEOUT: 5, dyson.CONF_RETRY: 2}})
self.assertEqual(mocked_login.call_count, 1)
self.assertEqual(mocked_devices.call_count, 1)
self.assertEqual(len(self.hass.data[d... |
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.mock_publish = mock_mqtt_component(self.hass)
|
'Stop down everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test the controlling state via topic.'
| def test_state_via_state_topic(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP'}}))
state = self.hass.states.get('cover.test')
self.... |
'Test the controlling state via topic.'
| def test_state_via_template(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'value_template': '{{ (value | multiply(0.01)) | int }}'}}))
state = self.hass.states.get('cover.test')
sel... |
'Test changing state optimistically.'
| def test_optimistic_state_change(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'command_topic': 'command-topic', 'qos': 0}}))
state = self.hass.states.get('cover.test')
self.assertEqual(STATE_UNKNOWN, state.state)
cover.open_cover(self.hass, 'cover.test')
self.hass.bloc... |
'Test the sending of open_cover.'
| def test_send_open_cover_command(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 2}}))
state = self.hass.states.get('cover.test')
self.assertEqual(STATE_UNKNOWN, state.state)
cover.open_cover(self.hass, 'c... |
'Test the sending of close_cover.'
| def test_send_close_cover_command(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 2}}))
state = self.hass.states.get('cover.test')
self.assertEqual(STATE_UNKNOWN, state.state)
cover.close_cover(self.hass, '... |
'Test the sending of stop_cover.'
| def test_send_stop__cover_command(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 2}}))
state = self.hass.states.get('cover.test')
self.assertEqual(STATE_UNKNOWN, state.state)
cover.stop_cover(self.hass, 'c... |
'Test the current cover position.'
| def test_current_cover_position(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP'}}))
state_attributes_dict = self.hass.states.get('cover.test').att... |
'Test setting cover position.'
| def test_set_cover_position(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'set_position_topic': 'position-topic', 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP'}}))
state_attributes_dict ... |
'Test setting cover position via template.'
| def test_set_position_templated(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'set_position_topic': 'position-topic', 'set_position_template': '{{100-62}}', 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop'... |
'Test setting cover position via template.'
| def test_set_position_untemplated(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'set_position_topic': 'position-topic', 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP'}}))
cover.set_cover_positi... |
'Test with no command topic.'
| def test_no_command_topic(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command', 'tilt_status_topic': 'tilt-status'}}))
self.assertEqual(240, self.hass.states.get... |
'Test with command topic and tilt config.'
| def test_with_command_topic_and_tilt(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'command_topic': 'test', 'platform': 'mqtt', 'name': 'test', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command', 'tilt_status_topic': 'tilt-status'}}))
self.assertEqual(... |
'Test the defaults.'
| def test_tilt_defaults(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command', 'tilt_status_topic': ... |
'Test tilt defaults on close/open.'
| def test_tilt_via_invocation_defaults(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_to... |
'Test tilting to a given value.'
| def test_tilt_given_value(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_to... |
'Test tilt by updating status via MQTT.'
| def test_tilt_via_topic(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_to... |
'Test tilt status via MQTT with altered tilt range.'
| def test_tilt_via_topic_altered_range(self):
| self.assertTrue(setup_component(self.hass, cover.DOMAIN, {cover.DOMAIN: {'platform': 'mqtt', 'name': 'test', 'state_topic': 'state-topic', 'command_topic': 'command-topic', 'qos': 0, 'payload_open': 'OPEN', 'payload_close': 'CLOSE', 'payload_stop': 'STOP', 'tilt_command_topic': 'tilt-command-topic', 'tilt_status_to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.