chore: fix lint issues

ruff ruff ruff!

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
Milas Bowman 2023-11-20 16:10:38 -05:00
parent c9e3efddb8
commit 26e07251d4
2 changed files with 111 additions and 104 deletions

View File

@ -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(
'alpine', 'echo hello world', network=net_name,
networking_config=networking_config,

View File

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