Skip to content

Commit

Permalink
Merge pull request #358 from umohnani8/lint
Browse files Browse the repository at this point in the history
Fix lint issues
  • Loading branch information
openshift-merge-bot[bot] authored Dec 20, 2023
2 parents d6342f8 + ba05f89 commit 039b648
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 147 deletions.
30 changes: 14 additions & 16 deletions podman/domain/containers_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,22 +383,20 @@ def _render_payload(kwargs: MutableMapping[str, Any]) -> Dict[str, Any]:
del args[key]

# These keywords are not supported for various reasons.
unsupported_keys = set(args.keys()).intersection(
(
"blkio_weight",
"blkio_weight_device", # FIXME In addition to device Major/Minor include path
"device_cgroup_rules", # FIXME Where to map for Podman API?
"device_read_bps", # FIXME In addition to device Major/Minor include path
"device_read_iops", # FIXME In addition to device Major/Minor include path
"device_requests", # FIXME In addition to device Major/Minor include path
"device_write_bps", # FIXME In addition to device Major/Minor include path
"device_write_iops", # FIXME In addition to device Major/Minor include path
"domainname",
"network_disabled", # FIXME Where to map for Podman API?
"storage_opt", # FIXME Where to map for Podman API?
"tmpfs", # FIXME Where to map for Podman API?
)
)
unsupported_keys = set(args.keys()).intersection((
"blkio_weight",
"blkio_weight_device", # FIXME In addition to device Major/Minor include path
"device_cgroup_rules", # FIXME Where to map for Podman API?
"device_read_bps", # FIXME In addition to device Major/Minor include path
"device_read_iops", # FIXME In addition to device Major/Minor include path
"device_requests", # FIXME In addition to device Major/Minor include path
"device_write_bps", # FIXME In addition to device Major/Minor include path
"device_write_iops", # FIXME In addition to device Major/Minor include path
"domainname",
"network_disabled", # FIXME Where to map for Podman API?
"storage_opt", # FIXME Where to map for Podman API?
"tmpfs", # FIXME Where to map for Podman API?
))
if len(unsupported_keys) > 0:
raise TypeError(
f"""Keyword(s) '{" ,".join(unsupported_keys)}' are"""
Expand Down
59 changes: 24 additions & 35 deletions podman/tests/unit/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,14 @@ def test_start(self, mock):

@requests_mock.Mocker()
def test_stats(self, mock):
stream = [
{
"Error": None,
"Stats": [
{
"ContainerId": (
"87e1325c82424e49a00abdd4de08009eb76c7de8d228426a9b8af9318ced5ecd"
),
"Name": "evil_ptolemy",
"CPU": 1000.0,
}
],
}
]
stream = [{
"Error": None,
"Stats": [{
"ContainerId": "87e1325c82424e49a00abdd4de08009eb76c7de8d228426a9b8af9318ced5ecd",
"Name": "evil_ptolemy",
"CPU": 1000.0,
}],
}]
buffer = io.StringIO()
for entry in stream:
buffer.write(json.JSONEncoder().encode(entry))
Expand Down Expand Up @@ -413,28 +407,23 @@ def test_top(self, mock):

@requests_mock.Mocker()
def test_top_with_streaming(self, mock):
stream = [
{
"Processes": [
[
'jhonce',
'2417',
'2274',
'0',
'Mar01',
'?',
'00:00:01',
(
'/usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c'
' "/usr/bin/gnome-session"'
),
],
['jhonce', '5544', '3522', '0', 'Mar01', 'pts/1', '00:00:02', '-bash'],
['jhonce', '6140', '3522', '0', 'Mar01', 'pts/2', '00:00:00', '-bash'],
stream = [{
"Processes": [
[
'jhonce',
'2417',
'2274',
'0',
'Mar01',
'?',
'00:00:01',
'/usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "/usr/bin/gnome-session"',
],
"Titles": ["UID", "PID", "PPID", "C", "STIME", "TTY", "TIME CMD"],
}
]
['jhonce', '5544', '3522', '0', 'Mar01', 'pts/1', '00:00:02', '-bash'],
['jhonce', '6140', '3522', '0', 'Mar01', 'pts/2', '00:00:00', '-bash'],
],
"Titles": ["UID", "PID", "PPID", "C", "STIME", "TTY", "TIME CMD"],
}]

buffer = io.StringIO()
for entry in stream:
Expand Down
30 changes: 14 additions & 16 deletions podman/tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@ def tearDown(self) -> None:

@requests_mock.Mocker()
def test_list(self, mock):
stream = [
{
"Type": "pod",
"Action": "create",
"Actor": {
"ID": "",
"Attributes": {
"image": "",
"name": "",
"containerExitCode": 0,
},
stream = [{
"Type": "pod",
"Action": "create",
"Actor": {
"ID": "",
"Attributes": {
"image": "",
"name": "",
"containerExitCode": 0,
},
"Scope": "local",
"Time": 1615845480,
"TimeNano": 1615845480,
}
]
},
"Scope": "local",
"Time": 1615845480,
"TimeNano": 1615845480,
}]
buffer = io.StringIO()
for item in stream:
buffer.write(json.JSONEncoder().encode(item))
Expand Down
18 changes: 8 additions & 10 deletions podman/tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ def test_history(self, mock):
adapter = mock.get(
tests.LIBPOD_URL
+ "/images/326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab/history",
json=[
{
"Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab",
"Comment": "",
"Created": 1614208404,
"CreatedBy": "2021-02-24T23:13:24+00:00",
"Tags": ["latest"],
"Size": 1024,
}
],
json=[{
"Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab",
"Comment": "",
"Created": 1614208404,
"CreatedBy": "2021-02-24T23:13:24+00:00",
"Tags": ["latest"],
"Size": 1024,
}],
)
image = Image(attrs=FIRST_IMAGE, client=self.client.api)

Expand Down
20 changes: 8 additions & 12 deletions podman/tests/unit/test_imagesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ def test_prune(self, mock):
"""Unit test Images prune()."""
mock.post(
tests.LIBPOD_URL + "/images/prune",
json=[
{
"Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab",
"Err": None,
"Size": 1024,
}
],
json=[{
"Id": "326dd9d7add24646a325e8eaa82125294027db2332e49c5828d96312c5d773ab",
"Err": None,
"Size": 1024,
}],
)

results = self.client.images.prune()
Expand Down Expand Up @@ -212,11 +210,9 @@ def test_prune_failure(self, mock):
"""Unit test to report error carried in response body."""
mock.post(
tests.LIBPOD_URL + "/images/prune",
json=[
{
"Err": "Test prune failure in response body.",
}
],
json=[{
"Err": "Test prune failure in response body.",
}],
)

with self.assertRaises(APIError) as e:
Expand Down
18 changes: 8 additions & 10 deletions podman/tests/unit/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@
"driver": "bridge",
"network_interface": "libpod_veth0",
"created": "2022-01-28T09:18:37.491308364-07:00",
"subnets": [
{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}
],
"subnets": [{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}],
"ipv6_enabled": False,
"internal": False,
"dns_enabled": False,
Expand Down
36 changes: 16 additions & 20 deletions podman/tests/unit/test_networksmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,14 @@
"driver": "bridge",
"network_interface": "libpod_veth0",
"created": "2022-01-28T09:18:37.491308364-07:00",
"subnets": [
{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}
],
"subnets": [{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}],
"ipv6_enabled": False,
"internal": False,
"dns_enabled": False,
Expand All @@ -80,16 +78,14 @@
"created": "2021-03-01T09:18:37.491308364-07:00",
"driver": "bridge",
"network_interface": "libpod_veth1",
"subnets": [
{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}
],
"subnets": [{
"subnet": "10.11.12.0/24",
"gateway": "10.11.12.1",
"lease_range": {
"start_ip": "10.11.12.1",
"end_ip": "10.11.12.63",
},
}],
"ipv6_enabled": False,
"internal": False,
"dns_enabled": False,
Expand Down
52 changes: 24 additions & 28 deletions podman/tests/unit/test_podsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,34 +194,30 @@ def test_stats_without_decode(self, mock):
@requests_mock.Mocker()
def test_top_with_streaming(self, mock):
stream = [
[
{
'CPU': '2.53%',
'MemUsage': '49.15kB / 16.71GB',
'MemUsageBytes': '48KiB / 15.57GiB',
'Mem': '0.00%',
'NetIO': '7.638kB / 430B',
'BlockIO': '-- / --',
'PIDS': '1',
'Pod': '1c948ab42339',
'CID': 'd999c49a7b6c',
'Name': '1c948ab42339-infra',
}
],
[
{
'CPU': '1.46%',
'MemUsage': '57.23B / 16.71GB',
'MemUsageBytes': '48KiB / 15.57GiB',
'Mem': '0.00%',
'NetIO': '7.638kB / 430B',
'BlockIO': '-- / --',
'PIDS': '1',
'Pod': '1c948ab42339',
'CID': 'd999c49a7b6c',
'Name': '1c948ab42339-infra',
}
],
[{
'CPU': '2.53%',
'MemUsage': '49.15kB / 16.71GB',
'MemUsageBytes': '48KiB / 15.57GiB',
'Mem': '0.00%',
'NetIO': '7.638kB / 430B',
'BlockIO': '-- / --',
'PIDS': '1',
'Pod': '1c948ab42339',
'CID': 'd999c49a7b6c',
'Name': '1c948ab42339-infra',
}],
[{
'CPU': '1.46%',
'MemUsage': '57.23B / 16.71GB',
'MemUsageBytes': '48KiB / 15.57GiB',
'Mem': '0.00%',
'NetIO': '7.638kB / 430B',
'BlockIO': '-- / --',
'PIDS': '1',
'Pod': '1c948ab42339',
'CID': 'd999c49a7b6c',
'Name': '1c948ab42339-infra',
}],
]

buffer = io.StringIO()
Expand Down

0 comments on commit 039b648

Please sign in to comment.