当前位置: 首页>>代码示例>>Python>>正文


Python MockValue.data方法代码示例

本文整理汇总了Python中tests.mock.zwave.MockValue.data方法的典型用法代码示例。如果您正苦于以下问题:Python MockValue.data方法的具体用法?Python MockValue.data怎么用?Python MockValue.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.mock.zwave.MockValue的用法示例。


在下文中一共展示了MockValue.data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fan_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:28,代码来源:test_zwave.py

示例2: test_barrier_garage_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:32,代码来源:test_cover.py

示例3: test_trigger_sensor_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:31,代码来源:test_zwave.py

示例4: test_trigger_sensor_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:30,代码来源:test_binary_sensor.py

示例5: test_roller_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:30,代码来源:test_zwave.py

示例6: test_get_config

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:37,代码来源:test_api.py

示例7: test_get_usercodes_no_genreuser

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:28,代码来源:test_api.py

示例8: test_set_protection_value_nonexisting_node

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:28,代码来源:test_zwave.py

示例9: test_get_protection_values_nonexisting_node

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:27,代码来源:test_zwave.py

示例10: test_get_protection_values

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:36,代码来源:test_zwave.py

示例11: test_multilevelsensor_value_changed_integer

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:15,代码来源:test_sensor.py

示例12: test_multilevelsensor_value_changed_temp_fahrenheit

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:15,代码来源:test_zwave.py

示例13: test_dimmer_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:15,代码来源:test_zwave.py

示例14: test_multilevelsensor_value_changed_temp_celsius

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:15,代码来源:test_sensor.py

示例15: test_switch_value_changed

# 需要导入模块: from tests.mock.zwave import MockValue [as 别名]
# 或者: from tests.mock.zwave.MockValue import data [as 别名]
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,代码行数:15,代码来源:test_zwave.py


注:本文中的tests.mock.zwave.MockValue.data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。