Ejemplo n.º 1
0
def test_update_network__mesh_dry_run(
    api_agents_search, api_agents_get, with_pagination, api_connections
):
    config = {
        "topology": "mesh",
        "state": "present",
        "connections": {
            "agent1": {
                "state": "present",
            },
            "agent2": {
                "state": "absent",
            },
            "agent3": {
                "state": "present",
            },
            "agent4": {
                "state": "present",
            },
        },
    }
    assert (
        configure.configure_network_update(mock.Mock(spec=sdk.ApiClient), config, True)
        == False
    )
    assert sdk.ConnectionsApi.v1_network_connections_get.call_count == 1
    assert sdk.ConnectionsApi.v1_network_connections_remove.call_count == 0
    assert sdk.ConnectionsApi.v1_network_connections_create_p2_p.call_count == 0
Ejemplo n.º 2
0
def test_update_network__mesh(
    api_agents_search, api_agents_get, api_connections, with_pagination, config_mock
):
    config = {
        "topology": "mesh",
        "state": "present",
        "connections": {
            "agent1": {
                "state": "present",
            },
            "agent2": {
                "state": "absent",
            },
            "agent3": {
                "state": "present",
            },
            "agent5": {
                "state": "present",
            },
        },
    }
    assert (
        configure.configure_network_update(mock.Mock(spec=sdk.ApiClient), config, False)
        == True
    )
    assert sdk.ConnectionsApi.v1_network_connections_get.call_count == 2
    assert sdk.ConnectionsApi.v1_network_connections_remove.call_args_list == [
        mock.call(
            mock.ANY,
            body=models.V1NetworkConnectionsRemoveRequest(
                agent_connection_group_ids=[1, 2],
            ),
        ),
    ]
    assert sdk.ConnectionsApi.v1_network_connections_create_p2_p.call_args_list == [
        mock.call(
            mock.ANY,
            body=models.V1NetworkConnectionsCreateP2PRequest(
                agent_pairs=[
                    models.V1NetworkConnectionsCreateP2PRequestAgentPairs(
                        agent_1_id=1,
                        agent_2_id=5,
                    ),
                    models.V1NetworkConnectionsCreateP2PRequestAgentPairs(
                        agent_1_id=3,
                        agent_2_id=5,
                    ),
                ],
            ),
            _preload_content=False,
        )
    ]