本文整理汇总了Python中tests.common.mock_mqtt_component函数的典型用法代码示例。如果您正苦于以下问题:Python mock_mqtt_component函数的具体用法?Python mock_mqtt_component怎么用?Python mock_mqtt_component使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mock_mqtt_component函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_method
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(
setup_component(
self.hass,
device_tracker.DOMAIN,
{
device_tracker.DOMAIN: {
CONF_PLATFORM: "owntracks",
CONF_MAX_GPS_ACCURACY: 200,
CONF_WAYPOINT_IMPORT: True,
CONF_WAYPOINT_WHITELIST: ["jon", "greg"],
}
},
)
)
self.hass.states.set("zone.inner", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10})
self.hass.states.set(
"zone.inner_2", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10}
)
self.hass.states.set(
"zone.outer", "zoning", {"name": "zone", "latitude": 2.0, "longitude": 1.0, "radius": 100000}
)
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)
owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
开发者ID:molobrakos,项目名称:home-assistant,代码行数:33,代码来源:test_owntracks.py
示例2: setUp
def setUp(self): # pylint: disable=invalid-name
self.hass = ha.HomeAssistant()
mock_mqtt_component(self.hass)
self.calls = []
def record_call(service):
self.calls.append(service)
self.hass.services.register("test", "automation", record_call)
开发者ID:LucasZielke,项目名称:home-assistant,代码行数:9,代码来源:test_mqtt.py
示例3: setUp
def setUp(self): # pylint: disable=invalid-name
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.calls = []
def record_call(service):
self.calls.append(service)
self.hass.services.register('test', 'automation', record_call)
开发者ID:100dayproject,项目名称:home-assistant,代码行数:9,代码来源:test_mqtt.py
示例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.hass.config.components.append('group')
mock_mqtt_component(self.hass)
self.calls = []
def record_call(service):
self.calls.append(service)
self.hass.services.register('test', 'automation', record_call)
开发者ID:bdfoster,项目名称:blumate,代码行数:11,代码来源:test_mqtt.py
示例5: setUp
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.components.append('group')
mock_mqtt_component(self.hass)
self.calls = []
@callback
def record_call(service):
"""Helper to record calls."""
self.calls.append(service)
self.hass.services.register('test', 'automation', record_call)
开发者ID:Teagan42,项目名称:home-assistant,代码行数:13,代码来源:test_mqtt.py
示例6: setup_method
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(device_tracker.setup(self.hass, {
device_tracker.DOMAIN: {
CONF_PLATFORM: 'owntracks',
CONF_MAX_GPS_ACCURACY: 200
}}))
self.hass.states.set(
'zone.inner', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.inner_2', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.outer', 'zoning',
{
'name': 'zone',
'latitude': 2.0,
'longitude': 1.0,
'radius': 100000
})
self.hass.states.set(
'zone.passive', 'zoning',
{
'name': 'zone',
'latitude': 3.0,
'longitude': 1.0,
'radius': 10,
'passive': True
})
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)
owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
开发者ID:Cinntax,项目名称:home-assistant,代码行数:50,代码来源:test_owntracks.py
示例7: 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.mock_publish = mock_mqtt_component(self.hass)
self.default_config = {
CONF_PLATFORM: 'mqtt',
CONF_NAME: 'mqtttest',
CONF_COMMAND_TOPIC: 'vacuum/command',
mqtt.CONF_SEND_COMMAND_TOPIC: 'vacuum/send_command',
mqtt.CONF_BATTERY_LEVEL_TOPIC: 'vacuum/state',
mqtt.CONF_BATTERY_LEVEL_TEMPLATE:
'{{ value_json.battery_level }}',
mqtt.CONF_CHARGING_TOPIC: 'vacuum/state',
mqtt.CONF_CHARGING_TEMPLATE: '{{ value_json.charging }}',
mqtt.CONF_CLEANING_TOPIC: 'vacuum/state',
mqtt.CONF_CLEANING_TEMPLATE: '{{ value_json.cleaning }}',
mqtt.CONF_DOCKED_TOPIC: 'vacuum/state',
mqtt.CONF_DOCKED_TEMPLATE: '{{ value_json.docked }}',
mqtt.CONF_STATE_TOPIC: 'vacuum/state',
mqtt.CONF_STATE_TEMPLATE: '{{ value_json.state }}',
mqtt.CONF_FAN_SPEED_TOPIC: 'vacuum/state',
mqtt.CONF_FAN_SPEED_TEMPLATE: '{{ value_json.fan_speed }}',
mqtt.CONF_SET_FAN_SPEED_TOPIC: 'vacuum/set_fan_speed',
mqtt.CONF_FAN_SPEED_LIST: ['min', 'medium', 'high', 'max'],
}
开发者ID:tmcarr,项目名称:home-assistant,代码行数:26,代码来源:test_mqtt.py
示例8: setup_method
def setup_method(self, method):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(setup_component(self.hass, sensor.DOMAIN, {
sensor.DOMAIN: {
CONF_PLATFORM: 'mqtt_room',
CONF_NAME: NAME,
CONF_DEVICE_ID: DEVICE_ID,
CONF_STATE_TOPIC: 'room_presence',
CONF_QOS: DEFAULT_QOS,
CONF_TIMEOUT: 5
}}))
# Clear state between tests
self.hass.states.set(SENSOR_STATE, None)
开发者ID:EarthlingRich,项目名称:home-assistant,代码行数:16,代码来源:test_mqtt_room.py
示例9: setup_method
def setup_method(self, _):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
mock_component(self.hass, 'group')
mock_component(self.hass, 'zone')
patcher = patch('homeassistant.components.device_tracker.'
'DeviceTracker.async_update_config')
patcher.start()
self.addCleanup(patcher.stop)
orig_context = owntracks.OwnTracksContext
def store_context(*args):
self.context = orig_context(*args)
return self.context
with patch('homeassistant.components.device_tracker.async_load_config',
return_value=mock_coro([])), \
patch('homeassistant.components.device_tracker.'
'load_yaml_config_file', return_value=mock_coro({})), \
patch.object(owntracks, 'OwnTracksContext', store_context), \
assert_setup_component(1, device_tracker.DOMAIN):
assert setup_component(self.hass, device_tracker.DOMAIN, {
device_tracker.DOMAIN: {
CONF_PLATFORM: 'owntracks',
CONF_MAX_GPS_ACCURACY: 200,
CONF_WAYPOINT_IMPORT: True,
CONF_WAYPOINT_WHITELIST: ['jon', 'greg']
}})
self.hass.states.set(
'zone.inner', 'zoning', INNER_ZONE)
self.hass.states.set(
'zone.inner_2', 'zoning', INNER_ZONE)
self.hass.states.set(
'zone.outer', 'zoning', OUTER_ZONE)
# Clear state between tests
# NB: state "None" is not a state that is created by Device
# so when we compare state to None in the tests this
# is really checking that it is still in its original
# test case state. See Device.async_update.
self.hass.states.set(DEVICE_TRACKER_STATE, None)
开发者ID:fabfurnari,项目名称:home-assistant,代码行数:47,代码来源:test_owntracks.py
示例10: setup_method
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
mock_component(self.hass, 'group')
mock_component(self.hass, 'zone')
patch_load = patch(
'homeassistant.components.device_tracker.async_load_config',
return_value=mock_coro([]))
patch_load.start()
self.addCleanup(patch_load.stop)
patch_save = patch('homeassistant.components.device_tracker.'
'DeviceTracker.async_update_config')
patch_save.start()
self.addCleanup(patch_save.stop)
开发者ID:fripsy,项目名称:home-assistant,代码行数:17,代码来源:test_owntracks.py
示例11: setup_method
def setup_method(self, _):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
with assert_setup_component(1, device_tracker.DOMAIN):
assert setup_component(self.hass, device_tracker.DOMAIN, {
device_tracker.DOMAIN: {
CONF_PLATFORM: 'owntracks',
CONF_MAX_GPS_ACCURACY: 200,
CONF_WAYPOINT_IMPORT: True,
CONF_WAYPOINT_WHITELIST: ['jon', 'greg']
}})
self.hass.states.set(
'zone.inner', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.inner_2', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.outer', 'zoning',
{
'name': 'zone',
'latitude': 2.0,
'longitude': 1.0,
'radius': 100000
})
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)
owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
开发者ID:azogue,项目名称:home-assistant,代码行数:44,代码来源:test_owntracks.py
示例12: setup_method
def setup_method(self, method):
""" Init needed objects. """
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(device_tracker.setup(self.hass, {
device_tracker.DOMAIN: {
CONF_PLATFORM: 'owntracks'
}}))
self.hass.states.set(
'zone.inner', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.inner_2', 'zoning',
{
'name': 'zone',
'latitude': 2.1,
'longitude': 1.1,
'radius': 10
})
self.hass.states.set(
'zone.outer', 'zoning',
{
'name': 'zone',
'latitude': 2.0,
'longitude': 1.0,
'radius': 100000
})
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)
owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
开发者ID:bradsk88,项目名称:home-assistant,代码行数:39,代码来源:test_owntracks.py
示例13: setup_method
def setup_method(self, method):
""" Init needed objects. """
self.hass = get_test_home_assistant()
mock_mqtt_component(self.hass)
self.assertTrue(device_tracker.setup(self.hass, {device_tracker.DOMAIN: {CONF_PLATFORM: "owntracks"}}))
self.hass.states.set("zone.inner", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10})
self.hass.states.set(
"zone.inner_2", "zoning", {"name": "zone", "latitude": 2.1, "longitude": 1.1, "radius": 10}
)
self.hass.states.set(
"zone.outer", "zoning", {"name": "zone", "latitude": 2.0, "longitude": 1.0, "radius": 100000}
)
self.hass.states.set(
"zone.passive", "zoning", {"name": "zone", "latitude": 3.0, "longitude": 1.0, "radius": 10, "passive": True}
)
# Clear state between teste
self.hass.states.set(DEVICE_TRACKER_STATE, None)
owntracks.REGIONS_ENTERED = defaultdict(list)
owntracks.MOBILE_BEACONS_ACTIVE = defaultdict(list)
开发者ID:renekliment,项目名称:home-assistant,代码行数:23,代码来源:test_owntracks.py
示例14: setUp
def setUp(self): # pylint: disable=invalid-name
self.hass = ha.HomeAssistant()
self.mock_publish = mock_mqtt_component(self.hass)
开发者ID:FanaHOVA,项目名称:home-assistant,代码行数:3,代码来源:test_mqtt.py
示例15: setUp
def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.mock_publish = mock_mqtt_component(self.hass)
开发者ID:arsaboo,项目名称:home-assistant,代码行数:4,代码来源:test_alarm_control_panel.py
示例16: setUp
def setUp(self): # pylint: disable=invalid-name
self.hass = get_test_home_assistant(1)
mock_mqtt_component(self.hass)
self.calls = []
开发者ID:100dayproject,项目名称:home-assistant,代码行数:4,代码来源:test_mqtt.py
示例17: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
super(TestMqttEventStream, self).setUp()
self.hass = get_test_home_assistant()
self.mock_mqtt = mock_mqtt_component(self.hass)
开发者ID:Bart274,项目名称:home-assistant,代码行数:5,代码来源:test_mqtt_eventstream.py
示例18: setUp
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.mock_publish = mock_mqtt_component(self.hass)
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:4,代码来源:test_mqtt.py
示例19: setUp
def setUp(self): # pylint: disable=invalid-name
super(TestMqttEventStream, self).setUp()
self.hass = get_test_home_assistant()
self.mock_mqtt = mock_mqtt_component(self.hass)
开发者ID:100dayproject,项目名称:home-assistant,代码行数:4,代码来源:test_mqtt_eventstream.py
注:本文中的tests.common.mock_mqtt_component函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论