本文整理汇总了Python中tests.mock.zwave.MockValue类的典型用法代码示例。如果您正苦于以下问题:Python MockValue类的具体用法?Python MockValue怎么用?Python MockValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MockValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_set_protection_value_nonexisting_node
async def test_set_protection_value_nonexisting_node(hass, client):
"""Test setting protection value on nonexisting node."""
network = hass.data[DATA_NETWORK] = MagicMock()
node = MockNode(node_id=17,
command_classes=[const.COMMAND_CLASS_PROTECTION])
value = MockValue(
value_id=123456,
index=0,
instance=1,
command_class=const.COMMAND_CLASS_PROTECTION)
value.label = 'Protection Test'
value.data_items = ['Unprotected', 'Protection by Sequence',
'No Operation Possible']
value.data = 'Unprotected'
network.nodes = {17: node}
node.value = value
node.set_protection.return_value = False
resp = await client.post(
'/api/zwave/protection/18', data=json.dumps({
'value_id': '123456', 'selection': 'Protecton by Seuence'}))
assert resp.status == 404
result = await resp.json()
assert not node.set_protection.called
assert result == {'message': 'Node not found'}
开发者ID:Martwall,项目名称:home-assistant,代码行数:26,代码来源:test_zwave.py
示例2: test_fan_value_changed
def test_fan_value_changed(mock_openzwave):
"""Test value changed for zwave fan."""
node = MockNode()
value = MockValue(data=0, node=node)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = 10
value_changed(value)
assert device.is_on
assert device.speed == SPEED_LOW
value.data = 50
value_changed(value)
assert device.is_on
assert device.speed == SPEED_MEDIUM
value.data = 90
value_changed(value)
assert device.is_on
assert device.speed == SPEED_HIGH
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:26,代码来源:test_zwave.py
示例3: test_barrier_garage_value_changed
def test_barrier_garage_value_changed(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(data="Closed", node=node,
command_class=const.COMMAND_CLASS_BARRIER_OPERATOR)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass, node=node, values=values,
node_config={})
assert device.is_closed
assert not device.is_opening
assert not device.is_closing
value.data = "Opening"
value_changed(value)
assert not device.is_closed
assert device.is_opening
assert not device.is_closing
value.data = "Opened"
value_changed(value)
assert not device.is_closed
assert not device.is_opening
assert not device.is_closing
value.data = "Closing"
value_changed(value)
assert not device.is_closed
assert not device.is_opening
assert device.is_closing
开发者ID:arsaboo,项目名称:home-assistant,代码行数:30,代码来源:test_cover.py
示例4: test_trigger_sensor_value_changed
def test_trigger_sensor_value_changed(hass, mock_openzwave):
"""Test value changed for trigger sensor."""
node = MockNode(
manufacturer_id='013c', product_type='0002', product_id='0002')
value = MockValue(data=False, node=node)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = True
yield from hass.loop.run_in_executor(None, value_changed, value)
yield from hass.async_block_till_done()
assert device.invalidate_after is None
device.hass = hass
value.data = True
yield from hass.loop.run_in_executor(None, value_changed, value)
yield from hass.async_block_till_done()
assert device.is_on
test_time = device.invalidate_after - datetime.timedelta(seconds=1)
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
assert device.is_on
test_time = device.invalidate_after
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
assert not device.is_on
开发者ID:PetitCircuitLab,项目名称:home-assistant,代码行数:29,代码来源:test_zwave.py
示例5: test_get_usercodes_no_genreuser
def test_get_usercodes_no_genreuser(hass, test_client):
"""Test getting usercodes on node missing genre user."""
app = mock_http_component_app(hass)
ZWaveUserCodeView().register(app.router)
network = hass.data[DATA_NETWORK] = MagicMock()
node = MockNode(node_id=18,
command_classes=[const.COMMAND_CLASS_USER_CODE])
value = MockValue(
index=0,
command_class=const.COMMAND_CLASS_USER_CODE)
value.genre = const.GENRE_SYSTEM
value.label = 'label'
value.data = '1234'
node.values = {0: value}
network.nodes = {18: node}
node.get_values.return_value = node.values
client = yield from test_client(app)
resp = yield from client.get('/api/zwave/usercodes/18')
assert resp.status == 200
result = yield from resp.json()
assert result == {}
开发者ID:tedstriker,项目名称:home-assistant,代码行数:26,代码来源:test_api.py
示例6: test_get_protection_values_nonexisting_node
async def test_get_protection_values_nonexisting_node(hass, client):
"""Test getting protection values on node with wrong nodeid."""
network = hass.data[DATA_NETWORK] = MagicMock()
node = MockNode(node_id=18,
command_classes=[const.COMMAND_CLASS_PROTECTION])
value = MockValue(
value_id=123456,
index=0,
instance=1,
command_class=const.COMMAND_CLASS_PROTECTION)
value.label = 'Protection Test'
value.data_items = ['Unprotected', 'Protection by Sequence',
'No Operation Possible']
value.data = 'Unprotected'
network.nodes = {17: node}
node.value = value
resp = await client.get('/api/zwave/protection/18')
assert resp.status == 404
result = await resp.json()
assert not node.get_protections.called
assert not node.get_protection_item.called
assert not node.get_protection_items.called
assert result == {'message': 'Node not found'}
开发者ID:Martwall,项目名称:home-assistant,代码行数:25,代码来源:test_zwave.py
示例7: test_get_protection_values
async def test_get_protection_values(hass, client):
"""Test getting protection values on node."""
network = hass.data[DATA_NETWORK] = MagicMock()
node = MockNode(node_id=18,
command_classes=[const.COMMAND_CLASS_PROTECTION])
value = MockValue(
value_id=123456,
index=0,
instance=1,
command_class=const.COMMAND_CLASS_PROTECTION)
value.label = 'Protection Test'
value.data_items = ['Unprotected', 'Protection by Sequence',
'No Operation Possible']
value.data = 'Unprotected'
network.nodes = {18: node}
node.value = value
node.get_protection_item.return_value = "Unprotected"
node.get_protection_items.return_value = value.data_items
node.get_protections.return_value = {value.value_id: 'Object'}
resp = await client.get('/api/zwave/protection/18')
assert resp.status == 200
result = await resp.json()
assert node.get_protections.called
assert node.get_protection_item.called
assert node.get_protection_items.called
assert result == {
'value_id': '123456',
'selected': 'Unprotected',
'options': ['Unprotected', 'Protection by Sequence',
'No Operation Possible']
}
开发者ID:Martwall,项目名称:home-assistant,代码行数:34,代码来源:test_zwave.py
示例8: test_trigger_sensor_value_changed
async def test_trigger_sensor_value_changed(hass, mock_openzwave):
"""Test value changed for trigger sensor."""
node = MockNode(
manufacturer_id='013c', product_type='0002', product_id='0002')
value = MockValue(data=False, node=node)
value_off_delay = MockValue(data=15, node=node)
values = MockEntityValues(primary=value, off_delay=value_off_delay)
device = binary_sensor.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = True
await hass.async_add_job(value_changed, value)
assert device.invalidate_after is None
device.hass = hass
value.data = True
await hass.async_add_job(value_changed, value)
assert device.is_on
test_time = device.invalidate_after - datetime.timedelta(seconds=1)
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
assert device.is_on
test_time = device.invalidate_after
with patch('homeassistant.util.dt.utcnow', return_value=test_time):
assert not device.is_on
开发者ID:arsaboo,项目名称:home-assistant,代码行数:28,代码来源:test_binary_sensor.py
示例9: test_roller_value_changed
def test_roller_value_changed(mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(data=None, node=node,
command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL)
values = MockEntityValues(primary=value, open=None, close=None, node=node)
device = zwave.get_device(node=node, values=values, node_config={})
assert device.current_cover_position is None
assert device.is_closed is None
value.data = 2
value_changed(value)
assert device.current_cover_position == 0
assert device.is_closed
value.data = 35
value_changed(value)
assert device.current_cover_position == 35
assert not device.is_closed
value.data = 97
value_changed(value)
assert device.current_cover_position == 100
assert not device.is_closed
开发者ID:nunofgs,项目名称:home-assistant,代码行数:28,代码来源:test_zwave.py
示例10: test_switch_value_changed
def test_switch_value_changed(mock_openzwave):
"""Test value changed for Z-Wave switch."""
node = MockNode()
value = MockValue(data=False, node=node)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = True
value_changed(value)
assert device.is_on
开发者ID:azogue,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py
示例11: test_dimmer_value_changed
def test_dimmer_value_changed(mock_openzwave):
"""Test value changed for dimmer lights."""
node = MockNode()
value = MockValue(data=0, node=node)
device = zwave.get_device(node, value, {})
assert not device.is_on
value.data = 46
value_changed(value)
assert device.is_on
assert device.brightness == 118
开发者ID:zebpalmer,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py
示例12: test_alarm_sensor_value_changed
def test_alarm_sensor_value_changed(mock_openzwave):
"""Test value changed for Z-Wave sensor."""
node = MockNode(command_classes=[const.COMMAND_CLASS_ALARM,
const.COMMAND_CLASS_SENSOR_ALARM])
value = MockValue(data=12.34, node=node, units='%')
values = MockEntityValues(primary=value)
device = sensor.get_device(node=node, values=values, node_config={})
assert device.state == 12.34
assert device.unit_of_measurement == '%'
value.data = 45.67
value_changed(value)
assert device.state == 45.67
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py
示例13: test_multilevelsensor_value_changed_temp_celsius
def test_multilevelsensor_value_changed_temp_celsius(mock_openzwave):
"""Test value changed for Z-Wave multilevel sensor for temperature."""
node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
const.COMMAND_CLASS_METER])
value = MockValue(data=38.85555, units='C', node=node)
values = MockEntityValues(primary=value)
device = sensor.get_device(node=node, values=values, node_config={})
assert device.state == 38.9
assert device.unit_of_measurement == homeassistant.const.TEMP_CELSIUS
value.data = 37.95555
value_changed(value)
assert device.state == 38.0
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py
示例14: test_multilevelsensor_value_changed_integer
def test_multilevelsensor_value_changed_integer(mock_openzwave):
"""Test value changed for Z-Wave multilevel sensor for other units."""
node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
const.COMMAND_CLASS_METER])
value = MockValue(data=5, units='counts', node=node)
values = MockEntityValues(primary=value)
device = sensor.get_device(node=node, values=values, node_config={})
assert device.state == 5
assert device.unit_of_measurement == 'counts'
value.data = 6
value_changed(value)
assert device.state == 6
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py
示例15: test_multilevelsensor_value_changed_temp_fahrenheit
def test_multilevelsensor_value_changed_temp_fahrenheit(mock_openzwave):
"""Test value changed for Z-Wave multilevel sensor for temperature."""
node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
const.COMMAND_CLASS_METER])
value = MockValue(data=190.95555, units='F', node=node)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert device.state == 191.0
assert device.unit_of_measurement == homeassistant.const.TEMP_FAHRENHEIT
value.data = 197.95555
value_changed(value)
assert device.state == 198.0
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py
示例16: test_switch_garage_value_changed
def test_switch_garage_value_changed(hass, mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(data=False, node=node,
command_class=const.COMMAND_CLASS_SWITCH_BINARY)
values = MockEntityValues(primary=value, node=node)
device = cover.get_device(hass=hass, node=node, values=values,
node_config={})
assert device.is_closed
value.data = True
value_changed(value)
assert not device.is_closed
开发者ID:arsaboo,项目名称:home-assistant,代码行数:14,代码来源:test_cover.py
示例17: test_dimmer_value_changed
def test_dimmer_value_changed(mock_openzwave):
"""Test value changed for dimmer lights."""
node = MockNode()
value = MockValue(data=0, node=node)
values = MockLightValues(primary=value)
device = light.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = 46
value_changed(value)
assert device.is_on
assert device.brightness == 118
开发者ID:arsaboo,项目名称:home-assistant,代码行数:14,代码来源:test_light.py
示例18: test_binary_sensor_value_changed
def test_binary_sensor_value_changed(mock_openzwave):
"""Test value changed for binary sensor."""
node = MockNode()
value = MockValue(data=False, node=node,
command_class=const.COMMAND_CLASS_SENSOR_BINARY)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert not device.is_on
value.data = True
value_changed(value)
assert device.is_on
开发者ID:PetitCircuitLab,项目名称:home-assistant,代码行数:14,代码来源:test_zwave.py
示例19: test_garage_value_changed
def test_garage_value_changed(mock_openzwave):
"""Test position changed."""
node = MockNode()
value = MockValue(data=False, node=node,
command_class=const.COMMAND_CLASS_BARRIER_OPERATOR)
values = MockEntityValues(primary=value, node=node)
device = zwave.get_device(node=node, values=values, node_config={})
assert device.is_closed
value.data = True
value_changed(value)
assert not device.is_closed
开发者ID:nunofgs,项目名称:home-assistant,代码行数:14,代码来源:test_zwave.py
示例20: test_get_config
def test_get_config(hass, test_client):
"""Test getting config on node."""
app = mock_http_component_app(hass)
ZWaveNodeConfigView().register(app.router)
network = hass.data[DATA_NETWORK] = MagicMock()
node = MockNode(node_id=2)
value = MockValue(
index=12,
command_class=const.COMMAND_CLASS_CONFIGURATION)
value.label = 'label'
value.help = 'help'
value.type = 'type'
value.data = 'data'
value.data_items = ['item1', 'item2']
value.max = 'max'
value.min = 'min'
node.values = {12: value}
network.nodes = {2: node}
node.get_values.return_value = node.values
client = yield from test_client(app)
resp = yield from client.get('/api/zwave/config/2')
assert resp.status == 200
result = yield from resp.json()
assert result == {'12': {'data': 'data',
'data_items': ['item1', 'item2'],
'help': 'help',
'label': 'label',
'max': 'max',
'min': 'min',
'type': 'type'}}
开发者ID:tedstriker,项目名称:home-assistant,代码行数:35,代码来源:test_api.py
注:本文中的tests.mock.zwave.MockValue类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论