mirror of https://github.com/docker/docker-py.git
chore: fix lint issues
ruff ruff ruff! Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
c9e3efddb8
commit
26e07251d4
|
@ -157,7 +157,7 @@ class ContainerCollectionTest(BaseIntegrationTest):
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
with pytest.raises(docker.errors.APIError) as e:
|
with pytest.raises(docker.errors.APIError):
|
||||||
container = client.containers.run(
|
container = client.containers.run(
|
||||||
'alpine', 'echo hello world', network=net_name,
|
'alpine', 'echo hello world', network=net_name,
|
||||||
networking_config=networking_config,
|
networking_config=networking_config,
|
||||||
|
|
|
@ -41,77 +41,73 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
create_kwargs = _create_container_args(dict(
|
create_kwargs = _create_container_args({
|
||||||
image='alpine',
|
'image': 'alpine',
|
||||||
command='echo hello world',
|
'command': 'echo hello world',
|
||||||
blkio_weight_device=[{'Path': 'foo', 'Weight': 3}],
|
'blkio_weight_device': [{'Path': 'foo', 'Weight': 3}],
|
||||||
blkio_weight=2,
|
'blkio_weight': 2,
|
||||||
cap_add=['foo'],
|
'cap_add': ['foo'],
|
||||||
cap_drop=['bar'],
|
'cap_drop': ['bar'],
|
||||||
cgroup_parent='foobar',
|
'cgroup_parent': 'foobar',
|
||||||
cgroupns='host',
|
'cgroupns': 'host',
|
||||||
cpu_period=1,
|
'cpu_period': 1,
|
||||||
cpu_quota=2,
|
'cpu_quota': 2,
|
||||||
cpu_shares=5,
|
'cpu_shares': 5,
|
||||||
cpuset_cpus='0-3',
|
'cpuset_cpus': '0-3',
|
||||||
detach=False,
|
'detach': False,
|
||||||
device_read_bps=[{'Path': 'foo', 'Rate': 3}],
|
'device_read_bps': [{'Path': 'foo', 'Rate': 3}],
|
||||||
device_read_iops=[{'Path': 'foo', 'Rate': 3}],
|
'device_read_iops': [{'Path': 'foo', 'Rate': 3}],
|
||||||
device_write_bps=[{'Path': 'foo', 'Rate': 3}],
|
'device_write_bps': [{'Path': 'foo', 'Rate': 3}],
|
||||||
device_write_iops=[{'Path': 'foo', 'Rate': 3}],
|
'device_write_iops': [{'Path': 'foo', 'Rate': 3}],
|
||||||
devices=['/dev/sda:/dev/xvda:rwm'],
|
'devices': ['/dev/sda:/dev/xvda:rwm'],
|
||||||
dns=['8.8.8.8'],
|
'dns': ['8.8.8.8'],
|
||||||
domainname='example.com',
|
'domainname': 'example.com',
|
||||||
dns_opt=['foo'],
|
'dns_opt': ['foo'],
|
||||||
dns_search=['example.com'],
|
'dns_search': ['example.com'],
|
||||||
entrypoint='/bin/sh',
|
'entrypoint': '/bin/sh',
|
||||||
environment={'FOO': 'BAR'},
|
'environment': {'FOO': 'BAR'},
|
||||||
extra_hosts={'foo': '1.2.3.4'},
|
'extra_hosts': {'foo': '1.2.3.4'},
|
||||||
group_add=['blah'],
|
'group_add': ['blah'],
|
||||||
ipc_mode='foo',
|
'ipc_mode': 'foo',
|
||||||
kernel_memory=123,
|
'kernel_memory': 123,
|
||||||
labels={'key': 'value'},
|
'labels': {'key': 'value'},
|
||||||
links={'foo': 'bar'},
|
'links': {'foo': 'bar'},
|
||||||
log_config={'Type': 'json-file', 'Config': {}},
|
'log_config': {'Type': 'json-file', 'Config': {}},
|
||||||
lxc_conf={'foo': 'bar'},
|
'lxc_conf': {'foo': 'bar'},
|
||||||
healthcheck={'test': 'true'},
|
'healthcheck': {'test': 'true'},
|
||||||
hostname='somehost',
|
'hostname': 'somehost',
|
||||||
mac_address='abc123',
|
'mac_address': 'abc123',
|
||||||
mem_limit=123,
|
'mem_limit': 123,
|
||||||
mem_reservation=123,
|
'mem_reservation': 123,
|
||||||
mem_swappiness=2,
|
'mem_swappiness': 2,
|
||||||
memswap_limit=456,
|
'memswap_limit': 456,
|
||||||
name='somename',
|
'name': 'somename',
|
||||||
network_disabled=False,
|
'network_disabled': False,
|
||||||
network='foo',
|
'network': 'foo',
|
||||||
networking_config=networking_config,
|
'networking_config': networking_config,
|
||||||
oom_kill_disable=True,
|
'oom_kill_disable': True,
|
||||||
oom_score_adj=5,
|
'oom_score_adj': 5,
|
||||||
pid_mode='host',
|
'pid_mode': 'host',
|
||||||
pids_limit=500,
|
'pids_limit': 500,
|
||||||
platform='linux',
|
'platform': 'linux',
|
||||||
ports={
|
'ports': {1111: 4567, 2222: None},
|
||||||
1111: 4567,
|
'privileged': True,
|
||||||
2222: None
|
'publish_all_ports': True,
|
||||||
},
|
'read_only': True,
|
||||||
privileged=True,
|
'restart_policy': {'Name': 'always'},
|
||||||
publish_all_ports=True,
|
'security_opt': ['blah'],
|
||||||
read_only=True,
|
'shm_size': 123,
|
||||||
restart_policy={'Name': 'always'},
|
'stdin_open': True,
|
||||||
security_opt=['blah'],
|
'stop_signal': 9,
|
||||||
shm_size=123,
|
'sysctls': {'foo': 'bar'},
|
||||||
stdin_open=True,
|
'tmpfs': {'/blah': ''},
|
||||||
stop_signal=9,
|
'tty': True,
|
||||||
sysctls={'foo': 'bar'},
|
'ulimits': [{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
|
||||||
tmpfs={'/blah': ''},
|
'user': 'bob',
|
||||||
tty=True,
|
'userns_mode': 'host',
|
||||||
ulimits=[{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
|
'uts_mode': 'host',
|
||||||
user='bob',
|
'version': DEFAULT_DOCKER_API_VERSION,
|
||||||
userns_mode='host',
|
'volume_driver': 'some_driver', 'volumes': [
|
||||||
uts_mode='host',
|
|
||||||
version=DEFAULT_DOCKER_API_VERSION,
|
|
||||||
volume_driver='some_driver',
|
|
||||||
volumes=[
|
|
||||||
'/home/user1/:/mnt/vol2',
|
'/home/user1/:/mnt/vol2',
|
||||||
'/var/www:/mnt/vol1:ro',
|
'/var/www:/mnt/vol1:ro',
|
||||||
'volumename:/mnt/vol3r',
|
'volumename:/mnt/vol3r',
|
||||||
|
@ -119,18 +115,18 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'/anothervolumewithnohostpath:ro',
|
'/anothervolumewithnohostpath:ro',
|
||||||
'C:\\windows\\path:D:\\hello\\world:rw'
|
'C:\\windows\\path:D:\\hello\\world:rw'
|
||||||
],
|
],
|
||||||
volumes_from=['container'],
|
'volumes_from': ['container'],
|
||||||
working_dir='/code'
|
'working_dir': '/code',
|
||||||
))
|
})
|
||||||
|
|
||||||
expected = dict(
|
expected = {
|
||||||
image='alpine',
|
'image': 'alpine',
|
||||||
command='echo hello world',
|
'command': 'echo hello world',
|
||||||
domainname='example.com',
|
'domainname': 'example.com',
|
||||||
detach=False,
|
'detach': False,
|
||||||
entrypoint='/bin/sh',
|
'entrypoint': '/bin/sh',
|
||||||
environment={'FOO': 'BAR'},
|
'environment': {'FOO': 'BAR'},
|
||||||
host_config={
|
'host_config': {
|
||||||
'Binds': [
|
'Binds': [
|
||||||
'/home/user1/:/mnt/vol2',
|
'/home/user1/:/mnt/vol2',
|
||||||
'/var/www:/mnt/vol1:ro',
|
'/var/www:/mnt/vol1:ro',
|
||||||
|
@ -153,9 +149,13 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'CpuQuota': 2,
|
'CpuQuota': 2,
|
||||||
'CpuShares': 5,
|
'CpuShares': 5,
|
||||||
'CpusetCpus': '0-3',
|
'CpusetCpus': '0-3',
|
||||||
'Devices': [{'PathOnHost': '/dev/sda',
|
'Devices': [
|
||||||
'CgroupPermissions': 'rwm',
|
{
|
||||||
'PathInContainer': '/dev/xvda'}],
|
'PathOnHost': '/dev/sda',
|
||||||
|
'CgroupPermissions': 'rwm',
|
||||||
|
'PathInContainer': '/dev/xvda',
|
||||||
|
},
|
||||||
|
],
|
||||||
'Dns': ['8.8.8.8'],
|
'Dns': ['8.8.8.8'],
|
||||||
'DnsOptions': ['foo'],
|
'DnsOptions': ['foo'],
|
||||||
'DnsSearch': ['example.com'],
|
'DnsSearch': ['example.com'],
|
||||||
|
@ -187,28 +187,35 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'ShmSize': 123,
|
'ShmSize': 123,
|
||||||
'Sysctls': {'foo': 'bar'},
|
'Sysctls': {'foo': 'bar'},
|
||||||
'Tmpfs': {'/blah': ''},
|
'Tmpfs': {'/blah': ''},
|
||||||
'Ulimits': [{"Name": "nofile", "Soft": 1024, "Hard": 2048}],
|
'Ulimits': [
|
||||||
|
{"Name": "nofile", "Soft": 1024, "Hard": 2048},
|
||||||
|
],
|
||||||
'UsernsMode': 'host',
|
'UsernsMode': 'host',
|
||||||
'UTSMode': 'host',
|
'UTSMode': 'host',
|
||||||
'VolumeDriver': 'some_driver',
|
'VolumeDriver': 'some_driver',
|
||||||
'VolumesFrom': ['container'],
|
'VolumesFrom': ['container'],
|
||||||
},
|
},
|
||||||
healthcheck={'test': 'true'},
|
'healthcheck': {'test': 'true'},
|
||||||
hostname='somehost',
|
'hostname': 'somehost',
|
||||||
labels={'key': 'value'},
|
'labels': {'key': 'value'},
|
||||||
mac_address='abc123',
|
'mac_address': 'abc123',
|
||||||
name='somename',
|
'name': 'somename',
|
||||||
network_disabled=False,
|
'network_disabled': False,
|
||||||
networking_config={'EndpointsConfig': {
|
'networking_config': {
|
||||||
'foo': {'Aliases': ['test'], 'DriverOpts': {'key1': 'a'}}}
|
'EndpointsConfig': {
|
||||||
|
'foo': {
|
||||||
|
'Aliases': ['test'],
|
||||||
|
'DriverOpts': {'key1': 'a'},
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
platform='linux',
|
'platform': 'linux',
|
||||||
ports=[('1111', 'tcp'), ('2222', 'tcp')],
|
'ports': [('1111', 'tcp'), ('2222', 'tcp')],
|
||||||
stdin_open=True,
|
'stdin_open': True,
|
||||||
stop_signal=9,
|
'stop_signal': 9,
|
||||||
tty=True,
|
'tty': True,
|
||||||
user='bob',
|
'user': 'bob',
|
||||||
volumes=[
|
'volumes': [
|
||||||
'/mnt/vol2',
|
'/mnt/vol2',
|
||||||
'/mnt/vol1',
|
'/mnt/vol1',
|
||||||
'/mnt/vol3r',
|
'/mnt/vol3r',
|
||||||
|
@ -216,8 +223,8 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'/anothervolumewithnohostpath',
|
'/anothervolumewithnohostpath',
|
||||||
'D:\\hello\\world'
|
'D:\\hello\\world'
|
||||||
],
|
],
|
||||||
working_dir='/code'
|
'working_dir': '/code',
|
||||||
)
|
}
|
||||||
|
|
||||||
assert create_kwargs == expected
|
assert create_kwargs == expected
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue