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


Python MockNode.value方法代码示例

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


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

示例1: test_set_protection_value_nonexisting_node

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import value [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

示例2: test_get_protection_values_nonexisting_node

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import value [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

示例3: test_get_protection_values

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import value [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

示例4: test_get_protection_values_without_protectionclass

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import value [as 别名]
async def test_get_protection_values_without_protectionclass(hass, client):
    """Test getting protection values on node without protectionclass."""
    network = hass.data[DATA_NETWORK] = MagicMock()
    node = MockNode(node_id=18)
    value = MockValue(
        value_id=123456,
        index=0,
        instance=1)
    network.nodes = {18: node}
    node.value = value

    resp = await client.get('/api/zwave/protection/18')

    assert resp.status == 200
    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 == {}
开发者ID:Martwall,项目名称:home-assistant,代码行数:21,代码来源:test_zwave.py

示例5: test_set_protection_value_missing_class

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import value [as 别名]
async def test_set_protection_value_missing_class(hass, client):
    """Test setting protection value on node without protectionclass."""
    network = hass.data[DATA_NETWORK] = MagicMock()
    node = MockNode(node_id=17)
    value = MockValue(
        value_id=123456,
        index=0,
        instance=1)
    network.nodes = {17: node}
    node.value = value
    node.set_protection.return_value = False

    resp = await client.post(
        '/api/zwave/protection/17', 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': 'No protection commandclass on this node'}
开发者ID:Martwall,项目名称:home-assistant,代码行数:22,代码来源:test_zwave.py


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