Пример #1
0
def test_from_state():
    """Test from_state method."""
    state = json.loads(load_fixture("basic_dump.txt").split("\n")[0])["state"]

    node = node_pkg.Node(None, state["nodes"][0])

    assert node.node_id == 1
    assert node.index == 0
    assert node.status == 4
    assert node.ready is True
    assert node.device_class.basic.key == 2
    assert node.device_class.generic.label == "Static Controller"
    assert node.device_class.mandatory_supported_ccs == []
    assert node.device_class.mandatory_controlled_ccs == [32]

    assert node.is_listening is True
    assert node.is_frequent_listening is False
    assert node.is_routing is False
    assert node.max_baud_rate == 40000
    assert node.is_secure is False
    assert node.version == 4
    assert node.is_beaming is True
    assert node.manufacturer_id == 134
    assert node.product_id == 90
    assert node.product_type == 257
    for attr, value in DEVICE_CONFIG_FIXTURE.items():
        assert getattr(node.device_config, attr) == value
    assert node.label == "ZW090"
    assert node.neighbors == [31, 32, 33, 36, 37, 39, 52]
    assert node.interview_attempts == 1
    assert len(node.endpoints) == 1
    assert node.endpoints[0].index == 0
Пример #2
0
def test_from_state():
    """Test from_state method."""
    state = json.loads(
        load_fixture("basic_dump.txt").split("\n")[0])["result"]["state"]

    node = node_pkg.Node(None, state["nodes"][0])

    assert node.node_id == 1
    assert node.index == 0
    assert node.status == 4
    assert node.ready is True
    assert node.device_class.basic.key == 2
    assert node.device_class.generic.label == "Static Controller"
    assert node.device_class.mandatory_supported_ccs == []
    assert node.device_class.mandatory_controlled_ccs == [32]

    assert node.is_listening is True
    assert node.is_frequent_listening is False
    assert node.is_routing is False
    assert node.max_data_rate == 100000
    assert node.supported_data_rates == [40000, 100000]
    assert node.is_secure is False
    assert node.protocol_version == ProtocolVersion.VERSION_4_5X_OR_6_0X
    assert node.supports_beaming is True
    assert node.supports_security is False
    assert node.zwave_plus_node_type is None
    assert node.zwave_plus_role_type is None
    assert node.manufacturer_id == 134
    assert node.product_id == 90
    assert node.product_type == 257
    assert node.label == "ZW090"
    assert node.interview_attempts == 0
    assert node.installer_icon is None
    assert node.user_icon is None
    assert node.firmware_version is None
    assert node.name is None
    assert node.zwave_plus_version is None
    assert node.location is None
    assert node.endpoint_count_is_dynamic is None
    assert node.endpoints_have_identical_capabilities is None
    assert node.individual_endpoint_count is None
    assert node.aggregated_endpoint_count is None
    assert node.interview_stage == "Neighbors"
    assert len(node.command_classes) == 0
    assert len(node.endpoints) == 1
    assert node.endpoints[0].index == 0
    device_class = node.endpoints[0].device_class
    assert device_class.basic.key == 2
    assert device_class.generic.key == 2
    assert device_class.specific.key == 1
    stats = node.statistics
    assert (stats.commands_dropped_rx == stats.commands_dropped_tx ==
            stats.commands_rx == stats.commands_tx == stats.timeout_response ==
            0)
Пример #3
0
def test_node_inclusion():
    """Emulate a node being added."""
    # when a node node is added, it has minimal info first
    node = node_pkg.Node(
        None, {"nodeId": 52, "status": 1, "ready": False, "values": []}
    )
    assert node.node_id == 52
    assert node.status == 1
    assert not node.ready
    assert len(node.values) == 0
    # the ready event contains a full (and complete) dump of the node, including values
    state = json.loads(load_fixture("multisensor_6_state.json"))
    event = Event("ready", {"nodeState": state})
    node.receive_event(event)
    assert len(node.values) > 0