本文整理汇总了Python中tests.common.get_test_home_assistant函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_home_assistant函数的具体用法?Python get_test_home_assistant怎么用?Python get_test_home_assistant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_test_home_assistant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_platform_validator
def test_platform_validator():
"""Test platform validation."""
# Prepares loading
get_test_home_assistant()
schema = vol.Schema(cv.platform_validator('light'))
with pytest.raises(vol.MultipleInvalid):
schema('platform_that_does_not_exist')
schema('hue')
示例2: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.events = []
self.service1 = MagicMock()
self.service2 = MagicMock()
def mock_get_service(hass, config):
if config['name'] == 'demo1':
return self.service1
else:
return self.service2
with assert_setup_component(2), \
patch.object(demo, 'get_service', mock_get_service):
setup_component(self.hass, notify.DOMAIN, {
'notify': [{
'name': 'demo1',
'platform': 'demo'
}, {
'name': 'demo2',
'platform': 'demo'
}]
})
self.service = group.get_service(self.hass, {'services': [
{'service': 'demo1'},
{'service': 'demo2',
'data': {'target': 'unnamed device',
'data': {'test': 'message'}}}]})
assert self.service is not None
示例3: setup_method
def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
config = {
ip.DOMAIN: {
'platform': 'demo'
},
'camera': {
'platform': 'demo'
},
}
with patch('homeassistant.components.image_processing.demo.'
'DemoImageProcessingFace.should_poll',
new_callable=PropertyMock(return_value=False)):
setup_component(self.hass, ip.DOMAIN, config)
state = self.hass.states.get('camera.demo_camera')
self.url = "{0}{1}".format(
self.hass.config.api.base_url,
state.attributes.get(ATTR_ENTITY_PICTURE))
self.face_events = []
@callback
def mock_face_event(event):
"""Mock event."""
self.face_events.append(event)
self.hass.bus.listen('image_processing.detect_face', mock_face_event)
示例4: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.events = []
self.assertTrue(setup_component(self.hass, notify.DOMAIN, {
'notify': [{
'name': 'demo1',
'platform': 'demo'
}, {
'name': 'demo2',
'platform': 'demo'
}]
}))
self.service = group.get_service(self.hass, {'services': [
{'service': 'demo1'},
{'service': 'demo2',
'data': {'target': 'unnamed device',
'data': {'test': 'message'}}}]})
assert self.service is not None
def record_event(event):
"""Record event to send notification."""
self.events.append(event)
self.hass.bus.listen("notify", record_event)
示例5: setUp
def setUp(self): # pylint: disable=invalid-name
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.mailer = MockSMTP('localhost', 25, 5, '[email protected]', 1,
'testuser', 'testpass',
['[email protected]', '[email protected]'],
'HomeAssistant', 0)
示例6: setup_method
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.entity = entity.Entity()
self.entity.entity_id = 'test.overwrite_hidden_true'
self.hass = self.entity.hass = get_test_home_assistant()
self.entity.schedule_update_ha_state()
self.hass.block_till_done()
示例7: setup_method
def setup_method(self, method):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.rs = cmd_rs.CommandCover(self.hass, 'foo',
'command_open', 'command_close',
'command_stop', 'command_state',
None)
示例8: test_remove_lib_on_upgrade
def test_remove_lib_on_upgrade(self, mock_os, mock_shutil):
"""Test removal of library on upgrade."""
ha_version = '0.7.0'
mock_os.path.isdir = mock.Mock(return_value=True)
mock_open = mock.mock_open()
with mock.patch('homeassistant.config.open', mock_open, create=True):
opened_file = mock_open.return_value
opened_file.readline.return_value = ha_version
self.hass = get_test_home_assistant()
self.hass.config.path = mock.Mock()
config_util.process_ha_config_upgrade(self.hass)
hass_path = self.hass.config.path.return_value
self.assertEqual(mock_os.path.isdir.call_count, 1)
self.assertEqual(
mock_os.path.isdir.call_args, mock.call(hass_path)
)
self.assertEqual(mock_shutil.rmtree.call_count, 1)
self.assertEqual(
mock_shutil.rmtree.call_args, mock.call(hass_path)
)
示例9: setup_method
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.latitude = 32.87336
self.hass.config.longitude = 117.22743
self.port = mock.MagicMock()
self.switch = mfi.MfiSwitch(self.port)
示例10: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.states.set("light.Bowl", "on")
self.hass.states.set("switch.AC", "off")
event_decorators.HASS = self.hass
示例11: setUp
def setUp(self): # pylint: disable=invalid-name
""" Init needed objects. """
self.hass = get_test_home_assistant()
self.assertTrue(comps.setup(self.hass, {}))
self.hass.states.set('light.Bowl', STATE_ON)
self.hass.states.set('light.Ceiling', STATE_OFF)
示例12: setUp
def setUp(self): # pylint: disable=invalid-name
""" Init needed objects. """
self.hass = get_test_home_assistant()
loader.prepare(self.hass)
self.known_dev_path = self.hass.config.path(
device_tracker.KNOWN_DEVICES_FILE)
示例13: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.units = METRIC_SYSTEM
self.assertTrue(hvac.setup(self.hass, {'hvac': {
'platform': 'demo',
}}))
示例14: setUp
def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.key = 'foo'
self.lat = self.hass.config.latitude = 37.8267
self.lon = self.hass.config.longitude = -122.423
self.entities = []
示例15: setUp
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
controller_mock = mock.MagicMock()
dev_dict = {'address': 'a1', 'name': 'fake_switch'}
self.switch = mochad.MochadSwitch(self.hass, controller_mock,
dev_dict)