desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Stop everything that was started.'
| def teardown_method(self):
| self.hass.stop()
|
'Setup ffmpeg component.'
| def test_setup_component(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config)
assert (self.hass.data['ffmpeg'].binary == 'ffmpeg')
assert (self.hass.states.get('binary_sensor.ffmpeg_motion') is not None)
|
'Setup ffmpeg component.'
| @patch('haffmpeg.SensorMotion.open_sensor', return_value=mock_coro())
def test_setup_component_start(self, mock_start):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config)
assert (self.hass.data['ffmpeg'].binary == 'ffmpeg')
assert (self.hass.states.get('binary_sensor.ffmpeg_motion') is not None)
self.hass.start()
assert mock_start.called
entity = self... |
'Setup ffmpeg component.'
| @patch('haffmpeg.SensorMotion')
def test_setup_component_start_callback(self, mock_ffmpeg):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config)
assert (self.hass.data['ffmpeg'].binary == 'ffmpeg')
assert (self.hass.states.get('binary_sensor.ffmpeg_motion') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sens... |
'Mock add devices.'
| def add_devices(self, devices):
| for device in devices:
self.DEVICES.append(device)
|
'Initialize values for this testcase class.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.username = 'foo'
self.password = 'bar'
self.config = {'username': self.username, 'password': self.password}
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test for successfully setting up the SleepIQ platform.'
| @requests_mock.Mocker()
def test_setup(self, mock):
| mock_responses(mock)
setup_component(self.hass, 'sleepiq', {'sleepiq': self.config})
sleepiq.setup_platform(self.hass, self.config, self.add_devices, MagicMock())
self.assertEqual(2, len(self.DEVICES))
left_side = self.DEVICES[1]
self.assertEqual('SleepNumber ILE Test1 Is In Bed',... |
'Mock add devices.'
| def add_devices(self, devices, action):
| for device in devices:
self.DEVICES.append(device)
|
'Cleanup any data created from the tests.'
| def cleanup(self):
| if os.path.isfile(self.cache):
os.remove(self.cache)
|
'Initialize values for this testcase class.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.cache = get_test_config_dir(base_ring.DEFAULT_CACHEDB)
self.config = {'username': 'foo', 'password': 'bar', 'monitored_conditions': ['ding', 'motion']}
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
self.cleanup()
|
'Test the Ring sensor class and methods.'
| @requests_mock.Mocker()
def test_binary_sensor(self, mock):
| mock.post('https://api.ring.com/clients_api/session', text=load_fixture('ring_session.json'))
mock.get('https://api.ring.com/clients_api/ring_devices', text=load_fixture('ring_devices.json'))
mock.get('https://api.ring.com/clients_api/dings/active', text=load_fixture('ring_ding_active.json'))
base_ring.... |
'Set up things to be run when tests are started.'
| def setup_method(self, method):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def teardown_method(self, method):
| self.hass.stop()
|
'Test if source is above threshold.'
| def test_sensor_upper(self):
| config = {'binary_sensor': {'platform': 'threshold', 'threshold': '15', 'type': 'upper', 'entity_id': 'sensor.test_monitored'}}
assert setup_component(self.hass, 'binary_sensor', config)
self.hass.states.set('sensor.test_monitored', 16, {ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS})
self.hass.block_till_done... |
'Test if source is below threshold.'
| def test_sensor_lower(self):
| config = {'binary_sensor': {'platform': 'threshold', 'threshold': '15', 'name': 'Test_threshold', 'type': 'lower', 'entity_id': 'sensor.test_monitored'}}
assert setup_component(self.hass, 'binary_sensor', config)
self.hass.states.set('sensor.test_monitored', 16)
self.hass.block_till_done()
state = s... |
'Setup things to be run when tests are started.'
| def setup_method(self, method):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def teardown_method(self, method):
| self.hass.stop()
|
'Test up trend.'
| def test_up(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state'}}}})
self.hass.states.set('sensor.test_state', '1')
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '2')
self.hass... |
'Test down trend.'
| def test_down(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state'}}}})
self.hass.states.set('sensor.test_state', '2')
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '1')
self.hass... |
'Test up trend with custom message.'
| def test__invert_up(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state', 'invert': 'Yes'}}}})
self.hass.states.set('sensor.test_state', '1')
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '... |
'Test down trend with custom message.'
| def test_invert_down(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state', 'invert': 'Yes'}}}})
self.hass.states.set('sensor.test_state', '2')
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', '... |
'Test attribute up trend.'
| def test_attribute_up(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state', 'attribute': 'attr'}}}})
self.hass.states.set('sensor.test_state', 'State', {'attr': '1'})
self.hass.block_till_done()
self.hass.states.set... |
'Test attribute down trend.'
| def test_attribute_down(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state', 'attribute': 'attr'}}}})
self.hass.states.set('sensor.test_state', 'State', {'attr': '2'})
self.hass.block_till_done()
self.hass.states.set... |
'Test up trend.'
| def test_non_numeric(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state'}}}})
self.hass.states.set('sensor.test_state', 'Non')
self.hass.block_till_done()
self.hass.states.set('sensor.test_state', 'Numeric')
s... |
'Test attribute down trend.'
| def test_missing_attribute(self):
| assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend', 'sensors': {'test_trend_sensor': {'entity_id': 'sensor.test_state', 'attribute': 'missing'}}}})
self.hass.states.set('sensor.test_state', 'State', {'attr': '2'})
self.hass.block_till_done()
self.hass.states.... |
'Test invalid name.'
| def test_invalid_name_does_not_create(self):
| with assert_setup_component(0):
assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'template', 'sensors': {'test INVALID sensor': {'entity_id': 'sensor.test_state'}}}})
assert (self.hass.states.all() == [])
|
'Test invalid sensor.'
| def test_invalid_sensor_does_not_create(self):
| with assert_setup_component(0):
assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'template', 'sensors': {'test_trend_sensor': {'not_entity_id': 'sensor.test_state'}}}})
assert (self.hass.states.all() == [])
|
'Test no sensors.'
| def test_no_sensors_does_not_create(self):
| with assert_setup_component(0):
assert setup.setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'trend'}})
assert (self.hass.states.all() == [])
|
'Test binary sensor state.'
| def test_state(self):
| sensor = binary_sensor.BinarySensorDevice()
self.assertEqual(STATE_OFF, sensor.state)
with mock.patch('homeassistant.components.binary_sensor.BinarySensorDevice.is_on', new=False):
self.assertEqual(STATE_OFF, binary_sensor.BinarySensorDevice().state)
with mock.patch('homeassistant.components.bin... |
'Initialize values for this testcase class.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.lat = 37.8267
self.lon = (-122.423)
self.hass.config.latitude = self.lat
self.hass.config.longitude = self.lon
self.entities = []
|
'Stop everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test that the component is created and initialized as expected.'
| @requests_mock.Mocker()
def test_setup_and_initial_state(self, mock_req):
| uri = re.compile('http://services\\.swpc\\.noaa\\.gov/text/aurora-nowcast-map\\.txt')
mock_req.get(uri, text=load_fixture('aurora.txt'))
entities = []
def mock_add_entities(new_entities, update_before_add=False):
'Mock add entities.'
if update_before_add:
for entity in ... |
'Test that the the config can take a custom forecast threshold.'
| @requests_mock.Mocker()
def test_custom_threshold_works(self, mock_req):
| uri = re.compile('http://services\\.swpc\\.noaa\\.gov/text/aurora-nowcast-map\\.txt')
mock_req.get(uri, text=load_fixture('aurora.txt'))
entities = []
def mock_add_entities(new_entities, update_before_add=False):
'Mock add entities.'
if update_before_add:
for entity in ... |
'Setup things to be run when tests are started.'
| def setup_method(self, method):
| self.hass = get_test_home_assistant()
|
'Stop down everything that was started.'
| def teardown_method(self, method):
| self.hass.stop()
|
'Check a valid configuration.'
| def test_setup_platform_valid_config(self):
| with assert_setup_component(0, 'binary_sensor'):
assert setup_component(self.hass, 'binary_sensor', test_tcp.TEST_CONFIG)
|
'Check the invalid configuration.'
| def test_setup_platform_invalid_config(self):
| with assert_setup_component(0):
assert setup_component(self.hass, 'binary_sensor', {'binary_sensor': {'platform': 'tcp', 'porrt': 1234}})
|
'Check the supplied config and call add_devices with sensor.'
| @patch('homeassistant.components.sensor.tcp.TcpSensor.update')
def test_setup_platform_devices(self, mock_update):
| add_devices = Mock()
ret = bin_tcp.setup_platform(None, test_tcp.TEST_CONFIG, add_devices)
assert (ret is None)
assert add_devices.called
assert isinstance(add_devices.call_args[0][0][0], bin_tcp.TcpBinarySensor)
|
'Check the return that _state is value_on.'
| @patch('homeassistant.components.sensor.tcp.TcpSensor.update')
def test_is_on_true(self, mock_update):
| sensor = bin_tcp.TcpBinarySensor(self.hass, test_tcp.TEST_CONFIG['sensor'])
sensor._state = test_tcp.TEST_CONFIG['sensor'][tcp.CONF_VALUE_ON]
print sensor._state
assert sensor.is_on
|
'Check the return that _state is not the same as value_on.'
| @patch('homeassistant.components.sensor.tcp.TcpSensor.update')
def test_is_on_false(self, mock_update):
| sensor = bin_tcp.TcpBinarySensor(self.hass, test_tcp.TEST_CONFIG['sensor'])
sensor._state = '{} abc'.format(test_tcp.TEST_CONFIG['sensor'][tcp.CONF_VALUE_ON])
assert (not sensor.is_on)
|
'Setup things to be run when tests are started.'
| def setup_method(self):
| self.hass = get_test_home_assistant()
self.config_province = {'binary_sensor': {'platform': 'workday', 'country': 'DE', 'province': 'BW'}}
self.config_noprovince = {'binary_sensor': {'platform': 'workday', 'country': 'DE'}}
self.config_invalidprovince = {'binary_sensor': {'platform': 'workday', 'country... |
'Stop everything that was started.'
| def teardown_method(self):
| self.hass.stop()
|
'Setup workday component.'
| def test_setup_component_province(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_province)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
|
'Test if workdays are reported correctly.'
| @freeze_time('Mar 15th, 2017')
def test_workday_province(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_province)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state ==... |
'Test if weekends are reported correctly.'
| @freeze_time('Mar 12th, 2017')
def test_weekend_province(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_province)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state ==... |
'Test if public holidays are reported correctly.'
| @freeze_time('Jan 6th, 2017')
def test_public_holiday_province(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_province)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state ==... |
'Setup workday component.'
| def test_setup_component_noprovince(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_noprovince)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
|
'Test if public holidays are reported correctly.'
| @freeze_time('Jan 6th, 2017')
def test_public_holiday_noprovince(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_noprovince)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state ... |
'Test if public holidays are reported correctly.'
| @freeze_time('Mar 31st, 2017')
def test_public_holiday_state(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_state)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state == 'o... |
'Test if public holidays are reported correctly.'
| @freeze_time('Mar 31st, 2017')
def test_public_holiday_nostate(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_nostate)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.state == ... |
'Setup workday component.'
| def test_setup_component_invalidprovince(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_invalidprovince)
assert (self.hass.states.get('binary_sensor.workday_sensor') is None)
|
'Test if public holidays are reported correctly.'
| @freeze_time('Jan 6th, 2017')
def test_public_holiday_includeholiday(self):
| with assert_setup_component(1, 'binary_sensor'):
setup_component(self.hass, 'binary_sensor', self.config_includeholiday)
assert (self.hass.states.get('binary_sensor.workday_sensor') is not None)
self.hass.start()
entity = self.hass.states.get('binary_sensor.workday_sensor')
assert (entity.st... |
'Test if day_to_string is behaving correctly.'
| def test_day_to_string(self):
| assert (day_to_string(0) == 'mon')
assert (day_to_string(1) == 'tue')
assert (day_to_string(7) == 'holiday')
assert (day_to_string(8) is None)
|
'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 sensor setup.'
| def test_setup(self):
| config = {'name': 'Test', 'command': 'echo 1', 'payload_on': '1', 'payload_off': '0'}
devices = []
def add_dev_callback(devs, update):
'Add callback to add devices.'
for dev in devs:
devices.append(dev)
command_line.setup_platform(self.hass, config, add_dev_cal... |
'Test the setup with a bad configuration.'
| def test_setup_bad_config(self):
| config = {'name': 'test', 'platform': 'not_command_line'}
self.assertFalse(setup.setup_component(self.hass, 'test', {'command_line': config}))
|
'Test setting the state with a template.'
| def test_template(self):
| data = command_line.CommandSensorData('echo 10')
entity = command_line.CommandBinarySensor(self.hass, data, 'test', None, '1.0', '0', template.Template('{{ value | multiply(0.1) }}', self.hass))
entity.update()
self.assertEqual(STATE_ON, entity.state)
|
'Test setting the state with a template.'
| def test_sensor_off(self):
| data = command_line.CommandSensorData('echo 0')
entity = command_line.CommandBinarySensor(self.hass, data, 'test', None, '1', '0', None)
entity.update()
self.assertEqual(STATE_OFF, entity.state)
|
'Setup things to be run when tests are started.'
| def setUp(self):
| self.hass = get_test_home_assistant()
self.hass.config.units = METRIC_SYSTEM
self.assertTrue(setup_component(self.hass, climate.DOMAIN, {'climate': {'platform': 'demo'}}))
|
'Stop down everything that was started.'
| def tearDown(self):
| self.hass.stop()
|
'Test the initial parameters.'
| def test_setup_params(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(21, state.attributes.get('temperature'))
self.assertEqual('on', state.attributes.get('away_mode'))
self.assertEqual(22, state.attributes.get('current_temperature'))
self.assertEqual('On High', state.attributes.get('fan_mode'))
self... |
'Test the setup with default parameters.'
| def test_default_setup_params(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(7, state.attributes.get('min_temp'))
self.assertEqual(35, state.attributes.get('max_temp'))
self.assertEqual(30, state.attributes.get('min_humidity'))
self.assertEqual(99, state.attributes.get('max_humidity'))
|
'Test setting the target temperature without required attribute.'
| def test_set_only_target_temp_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(21, state.attributes.get('temperature'))
climate.set_temperature(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
self.assertEqual(21, state.attributes.get('temperature'))
|
'Test the setting of the target temperature.'
| def test_set_only_target_temp(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(21, state.attributes.get('temperature'))
climate.set_temperature(self.hass, 30, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(30.0, state.attributes.get('temperature'))
|
'Test the setting of the target temperature.'
| def test_set_only_target_temp_with_convert(self):
| state = self.hass.states.get(ENTITY_HEATPUMP)
self.assertEqual(20, state.attributes.get('temperature'))
climate.set_temperature(self.hass, 21, ENTITY_HEATPUMP)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_HEATPUMP)
self.assertEqual(21.0, state.attributes.get('temperature'))
|
'Test the setting of the target temperature with range.'
| def test_set_target_temp_range(self):
| state = self.hass.states.get(ENTITY_ECOBEE)
self.assertEqual(None, state.attributes.get('temperature'))
self.assertEqual(21.0, state.attributes.get('target_temp_low'))
self.assertEqual(24.0, state.attributes.get('target_temp_high'))
climate.set_temperature(self.hass, target_temp_high=25, target_temp... |
'Test setting the target temperature range without attribute.'
| def test_set_target_temp_range_bad_attr(self):
| state = self.hass.states.get(ENTITY_ECOBEE)
self.assertEqual(None, state.attributes.get('temperature'))
self.assertEqual(21.0, state.attributes.get('target_temp_low'))
self.assertEqual(24.0, state.attributes.get('target_temp_high'))
climate.set_temperature(self.hass, temperature=None, entity_id=ENTI... |
'Test setting the target humidity without required attribute.'
| def test_set_target_humidity_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(67, state.attributes.get('humidity'))
climate.set_humidity(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(67, state.attributes.get('humidity'))
|
'Test the setting of the target humidity.'
| def test_set_target_humidity(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(67, state.attributes.get('humidity'))
climate.set_humidity(self.hass, 64, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual(64.0, state.attributes.get('humidity'))
|
'Test setting fan mode without required attribute.'
| def test_set_fan_mode_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('On High', state.attributes.get('fan_mode'))
climate.set_fan_mode(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('On High', state.attributes.get('fan_mo... |
'Test setting of new fan mode.'
| def test_set_fan_mode(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('On High', state.attributes.get('fan_mode'))
climate.set_fan_mode(self.hass, 'On Low', ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('On Low', state.attributes.get('... |
'Test setting swing mode without required attribute.'
| def test_set_swing_mode_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('Off', state.attributes.get('swing_mode'))
climate.set_swing_mode(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('Off', state.attributes.get('swing_mode'))
|
'Test setting of new swing mode.'
| def test_set_swing(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('Off', state.attributes.get('swing_mode'))
climate.set_swing_mode(self.hass, 'Auto', ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('Auto', state.attributes.get('swing_mode'))... |
'Test setting operation mode without required attribute.
Also check the state.'
| def test_set_operation_bad_attr_and_state(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('cool', state.attributes.get('operation_mode'))
self.assertEqual('cool', state.state)
climate.set_operation_mode(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assert... |
'Test setting of new operation mode.'
| def test_set_operation(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('cool', state.attributes.get('operation_mode'))
self.assertEqual('cool', state.state)
climate.set_operation_mode(self.hass, 'heat', ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.asse... |
'Test setting the away mode without required attribute.'
| def test_set_away_mode_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('on', state.attributes.get('away_mode'))
climate.set_away_mode(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
self.assertEqual('on', state.attributes.get('away_mode'))
|
'Test setting the away mode on/true.'
| def test_set_away_mode_on(self):
| climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('on', state.attributes.get('away_mode'))
|
'Test setting the away mode off/false.'
| def test_set_away_mode_off(self):
| climate.set_away_mode(self.hass, False, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('off', state.attributes.get('away_mode'))
|
'Test setting the hold mode home.'
| def test_set_hold_mode_home(self):
| climate.set_hold_mode(self.hass, 'home', ENTITY_ECOBEE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ECOBEE)
self.assertEqual('home', state.attributes.get('hold_mode'))
|
'Test setting the hold mode away.'
| def test_set_hold_mode_away(self):
| climate.set_hold_mode(self.hass, 'away', ENTITY_ECOBEE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ECOBEE)
self.assertEqual('away', state.attributes.get('hold_mode'))
|
'Test setting the hold mode off/false.'
| def test_set_hold_mode_none(self):
| climate.set_hold_mode(self.hass, None, ENTITY_ECOBEE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_ECOBEE)
self.assertEqual(None, state.attributes.get('hold_mode'))
|
'Test setting the auxillary heater without required attribute.'
| def test_set_aux_heat_bad_attr(self):
| state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('off', state.attributes.get('aux_heat'))
climate.set_aux_heat(self.hass, None, ENTITY_CLIMATE)
self.hass.block_till_done()
self.assertEqual('off', state.attributes.get('aux_heat'))
|
'Test setting the axillary heater on/true.'
| def test_set_aux_heat_on(self):
| climate.set_aux_heat(self.hass, True, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('on', state.attributes.get('aux_heat'))
|
'Test setting the auxillary heater off/false.'
| def test_set_aux_heat_off(self):
| climate.set_aux_heat(self.hass, False, ENTITY_CLIMATE)
self.hass.block_till_done()
state = self.hass.states.get(ENTITY_CLIMATE)
self.assertEqual('off', state.attributes.get('aux_heat'))
|
'Setup things to be run when tests are started.'
| def setup_method(self, method):
| self.hass = get_test_home_assistant()
|
'Stop everything that was started.'
| def teardown_method(self, method):
| self.hass.stop()
shutil.rmtree(self.hass.config.path(panel_custom.PANEL_DIR), ignore_errors=True)
|
'Test if a web component is found in config panels dir.'
| @patch('homeassistant.components.panel_custom.register_panel')
def test_webcomponent_in_panels_dir(self, mock_register, _mock_setup):
| config = {'panel_custom': {'name': 'todomvc'}}
assert (not setup.setup_component(self.hass, 'panel_custom', config))
assert (not mock_register.called)
path = self.hass.config.path(panel_custom.PANEL_DIR)
os.mkdir(path)
self.hass.data.pop(setup.DATA_SETUP)
with open(os.path.join(path, 'todomv... |
'Test if a web component is found in config panels dir.'
| @patch('homeassistant.components.panel_custom.register_panel')
def test_webcomponent_custom_path(self, mock_register, _mock_setup):
| filename = 'mock.file'
config = {'panel_custom': {'name': 'todomvc', 'webcomponent_path': filename, 'sidebar_title': 'Sidebar Title', 'sidebar_icon': 'mdi:iconicon', 'url_path': 'nice_url', 'config': 5}}
with patch('os.path.isfile', Mock(return_value=False)):
assert (not setup.setup_component(sel... |
'Setup the tests.'
| def test_has_location_with_invalid_states(self):
| for state in (None, 1, 'hello', object):
self.assertFalse(location.has_location(state))
|
'Setup the tests.'
| def test_has_location_with_states_with_invalid_locations(self):
| state = State('hello.world', 'invalid', {ATTR_LATITUDE: 'no number', ATTR_LONGITUDE: 123.12})
self.assertFalse(location.has_location(state))
|
'Setup the tests.'
| def test_has_location_with_states_with_valid_location(self):
| state = State('hello.world', 'invalid', {ATTR_LATITUDE: 123.12, ATTR_LONGITUDE: 123.12})
self.assertTrue(location.has_location(state))
|
'Setup the tests.'
| def test_closest_with_no_states_with_location(self):
| state = State('light.test', 'on')
state2 = State('light.test', 'on', {ATTR_LATITUDE: 'invalid', ATTR_LONGITUDE: 123.45})
state3 = State('light.test', 'on', {ATTR_LONGITUDE: 123.45})
self.assertIsNone(location.closest(123.45, 123.45, [state, state2, state3]))
|
'Test .'
| def test_closest_returns_closest(self):
| state = State('light.test', 'on', {ATTR_LATITUDE: 124.45, ATTR_LONGITUDE: 124.45})
state2 = State('light.test', 'on', {ATTR_LATITUDE: 125.45, ATTR_LONGITUDE: 125.45})
self.assertEqual(state, location.closest(123.45, 123.45, [state, state2]))
|
'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 track point in time.'
| def test_track_point_in_time(self):
| before_birthday = datetime(1985, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
birthday_paulus = datetime(1986, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
after_birthday = datetime(1987, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
runs = []
track_point_in_utc_time(self.hass, (lambda x: runs.append(1)), birthday_paulus)
... |
'Test tracking time change.'
| def test_track_time_change(self):
| wildcard_runs = []
specific_runs = []
unsub = track_time_change(self.hass, (lambda x: wildcard_runs.append(1)))
unsub_utc = track_utc_time_change(self.hass, (lambda x: specific_runs.append(1)), second=[0, 30])
self._send_time_changed(datetime(2014, 5, 24, 12, 0, 0))
self.hass.block_till_done()
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.