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


Python MockNode.reset_mock方法代码示例

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


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

示例1: test_dimmer_turn_on

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import reset_mock [as 别名]
def test_dimmer_turn_on(mock_openzwave):
    """Test turning on a dimmable Z-Wave light."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    values = MockLightValues(primary=value)
    device = zwave.get_device(node=node, values=values, node_config={})

    device.turn_on()

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]
    assert value_id == value.value_id
    assert brightness == 255

    node.reset_mock()

    device.turn_on(**{ATTR_BRIGHTNESS: 120})

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 46  # int(120 / 255 * 99)

    with patch.object(zwave, '_LOGGER', MagicMock()) as mock_logger:
        device.turn_on(**{ATTR_TRANSITION: 35})
        assert mock_logger.debug.called
        assert node.set_dimmer.called
        msg, entity_id = mock_logger.debug.mock_calls[0][1]
        assert entity_id == device.entity_id
开发者ID:azogue,项目名称:home-assistant,代码行数:32,代码来源:test_zwave.py

示例2: test_fan_turn_on

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import reset_mock [as 别名]
def test_fan_turn_on(mock_openzwave):
    """Test turning on a zwave fan."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    values = MockEntityValues(primary=value)
    device = zwave.get_device(node=node, values=values, node_config={})

    device.turn_on()

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]
    assert value_id == value.value_id
    assert brightness == 255

    node.reset_mock()

    device.turn_on(speed=SPEED_OFF)

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 0

    node.reset_mock()

    device.turn_on(speed=SPEED_LOW)

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 1

    node.reset_mock()

    device.turn_on(speed=SPEED_MEDIUM)

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 50

    node.reset_mock()

    device.turn_on(speed=SPEED_HIGH)

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 99
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:55,代码来源:test_zwave.py

示例3: test_switch_turn_on_and_off

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import reset_mock [as 别名]
def test_switch_turn_on_and_off(mock_openzwave):
    """Test turning on a Z-Wave switch."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    values = MockEntityValues(primary=value)
    device = zwave.get_device(node=node, values=values, node_config={})

    device.turn_on()

    assert node.set_switch.called
    value_id, state = node.set_switch.mock_calls[0][1]
    assert value_id == value.value_id
    assert state is True
    node.reset_mock()

    device.turn_off()

    assert node.set_switch.called
    value_id, state = node.set_switch.mock_calls[0][1]
    assert value_id == value.value_id
    assert state is False
开发者ID:azogue,项目名称:home-assistant,代码行数:23,代码来源:test_zwave.py

示例4: test_dimmer_turn_on

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import reset_mock [as 别名]
def test_dimmer_turn_on(mock_openzwave):
    """Test turning on a dimmable Z-Wave light."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    device = zwave.get_device(node, value, {})

    device.turn_on()

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]
    assert value_id == value.value_id
    assert brightness == 255

    node.reset_mock()

    device.turn_on(**{ATTR_BRIGHTNESS: 120})

    assert node.set_dimmer.called
    value_id, brightness = node.set_dimmer.mock_calls[0][1]

    assert value_id == value.value_id
    assert brightness == 46  # int(120 / 255 * 99)
开发者ID:zebpalmer,项目名称:home-assistant,代码行数:24,代码来源:test_zwave.py


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