本文整理汇总了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
示例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
示例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
示例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)