async def test_remove_associations(controller, uuid4, mock_command):
    """Test remove associations."""

    ack_commands = mock_command(
        {"command": "controller.remove_associations"},
        {},
    )

    node_id = 52
    group = 0
    associations = [
        association_pkg.Association(node_id=5, endpoint=0),
        association_pkg.Association(node_id=10),
    ]

    await controller.async_remove_associations(node_id, group, associations)

    assert len(ack_commands) == 1
    assert ack_commands[0] == {
        "command": "controller.remove_associations",
        "messageId": uuid4,
        "nodeId": node_id,
        "group": group,
        "associations": [
            {"nodeId": 5, "endpoint": 0},
            {"nodeId": 10, "endpoint": None},
        ],
    }
Ejemplo n.º 2
0
async def test_is_association_allowed(controller, uuid4, mock_command):
    """Test is association allowed."""

    ack_commands = mock_command(
        {"command": "controller.is_association_allowed"},
        {"allowed": True},
    )

    node_id = 52
    group = 0
    association = association_pkg.Association(node_id=5, endpoint=0)

    assert await controller.async_is_association_allowed(
        node_id, group, association)

    assert len(ack_commands) == 1
    assert ack_commands[0] == {
        "command": "controller.is_association_allowed",
        "messageId": uuid4,
        "nodeId": node_id,
        "group": group,
        "association": {
            "nodeId": 5,
            "endpoint": 0
        },
    }