コード例 #1
0
def test_delete_connection(runner, login_mock):
    with mock.patch.object(
        ctl.sdk.ConnectionsApi, "v1_network_connections_remove", autospec=True
    ) as the_mock:
        runner.invoke(ctl.delete_connection, "123")
        the_mock.assert_called_once_with(
            mock.ANY,
            models.V1NetworkConnectionsRemoveRequest(agent_connection_group_ids=(123,)),
        )
コード例 #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,
        )
    ]
コード例 #3
0
def test_delete_connections(api_connections):
    result = configure.delete_connections(
        mock.Mock(spec=sdk.ApiClient),
        [(13, 11), (14, 13)],
    )
    sdk.ConnectionsApi.v1_network_connections_remove.assert_called_once()
    assert sdk.ConnectionsApi.v1_network_connections_remove.call_args_list == [
        mock.call(
            mock.ANY,
            body=models.V1NetworkConnectionsRemoveRequest(
                agent_connection_group_ids=[1, 2],
            ),
        ),
    ]
コード例 #4
0
def test_delete_network(
    networks, api_agents_search, api_connections, with_pagination, delete_config
):
    assert (
        configure.configure_network_delete(
            mock.Mock(spec=sdk.ApiClient), delete_config, False
        )
        == True
    )
    assert sdk.ConnectionsApi.v1_network_connections_remove.call_args_list == [
        mock.call(
            mock.ANY,
            body=models.V1NetworkConnectionsRemoveRequest(
                agent_connection_group_ids=[1, 2],
            ),
        )
    ]
コード例 #5
0
ファイル: __main__.py プロジェクト: SyntropyNet/syntropy-cli
def delete_connection(ids, api):
    """Delete connections using their ID."""
    body = models.V1NetworkConnectionsRemoveRequest(
        agent_connection_group_ids=ids)
    sdk.ConnectionsApi(api).v1_network_connections_remove(body)