Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion podman/domain/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ class Network(PodmanResource):
@property
def id(self): # pylint: disable=invalid-name
"""str: Returns the identifier of the network."""
with suppress(KeyError):
if "Id" in self.attrs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd stick with the old behavior and simply return id. that's what we want.

return self.attrs["Id"]

if "id" in self.attrs:
return self.attrs["id"]

with suppress(KeyError):
sha256 = hashlib.sha256(self.attrs["name"].encode("ascii"))
return sha256.hexdigest()
Expand Down
7 changes: 7 additions & 0 deletions podman/tests/integration/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def test_network_crud(self):
names = [i.name for i in nets]
self.assertIn("integration_test", names)

with self.subTest("Get by ID"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this test actually fail if id or Id?

network = self.client.networks.get("integration_test")
net_id = network.id
assert isinstance(net_id, str)
network_by_id = self.client.networks.get(net_id)
self.assertEqual(network.name, network_by_id.name)

with self.subTest("Delete network"):
network = self.client.networks.get("integration_test")
network.remove(force=True)
Expand Down