How to use the aiodocker.utils.clean_networks function in aiodocker

To help you get started, we’ve selected a few aiodocker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiodocker / tests / test_utils.py View on Github external
def test_clean_networks():
    networks = []
    assert utils.clean_networks(networks) == []

    networks = ("test-network-1", "test-network-2")
    with pytest.raises(TypeError) as excinfo:
        result = utils.clean_networks(networks)
    assert "networks parameter must be a list." in str(excinfo.value)

    networks = ["test-network-1", "test-network-2"]
    result = [{"Target": "test-network-1"}, {"Target": "test-network-2"}]
    assert utils.clean_networks(networks) == result
github aio-libs / aiodocker / tests / test_utils.py View on Github external
def test_clean_networks():
    networks = []
    assert utils.clean_networks(networks) == []

    networks = ("test-network-1", "test-network-2")
    with pytest.raises(TypeError) as excinfo:
        result = utils.clean_networks(networks)
    assert "networks parameter must be a list." in str(excinfo.value)

    networks = ["test-network-1", "test-network-2"]
    result = [{"Target": "test-network-1"}, {"Target": "test-network-2"}]
    assert utils.clean_networks(networks) == result
github aio-libs / aiodocker / aiodocker / services.py View on Github external
format_env(k, v)
                for k, v in task_template["ContainerSpec"]["Env"].items()
            ]

        headers = None
        if auth:
            headers = {"X-Registry-Auth": compose_auth_header(auth, registry)}

        config = {
            "TaskTemplate": task_template,
            "Name": name,
            "Labels": labels,
            "Mode": mode,
            "UpdateConfig": update_config,
            "RollbackConfig": rollback_config,
            "Networks": clean_networks(networks),
            "EndpointSpec": endpoint_spec,
        }

        data = json.dumps(clean_map(config))

        response = await self.docker._query_json(
            "services/create", method="POST", data=data, headers=headers
        )
        return response