Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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