From cb21af7f69fc44572c9f9a326c84275ae2be9c63 Mon Sep 17 00:00:00 2001 From: Rob Murray Date: Wed, 13 Mar 2024 14:54:25 +0000 Subject: [PATCH] Fix tests that look at 'Aliases' Inspect output for 'NetworkSettings.Networks..Aliases' includes the container's short-id (although it will be removed in API v1.45, in moby 26.0). Signed-off-by: Rob Murray --- tests/integration/models_containers_test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py index 219b9a4cb..87ba89b1d 100644 --- a/tests/integration/models_containers_test.py +++ b/tests/integration/models_containers_test.py @@ -110,12 +110,12 @@ def test_run_with_networking_config(self): client.networks.create(net_name) self.tmp_networks.append(net_name) - test_aliases = ['hello'] + test_alias = 'hello' test_driver_opt = {'key1': 'a'} networking_config = { net_name: client.api.create_endpoint_config( - aliases=test_aliases, + aliases=[test_alias], driver_opt=test_driver_opt ) } @@ -132,8 +132,10 @@ def test_run_with_networking_config(self): assert 'NetworkSettings' in attrs assert 'Networks' in attrs['NetworkSettings'] assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name] - assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] == \ - test_aliases + # Expect Aliases to list 'test_alias' and the container's short-id. + # In API version 1.45, the short-id will be removed. + assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] \ + == [test_alias, attrs['Id'][:12]] assert attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] \ == test_driver_opt @@ -190,7 +192,9 @@ def test_run_with_networking_config_only_undeclared_network(self): assert 'NetworkSettings' in attrs assert 'Networks' in attrs['NetworkSettings'] assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name] - assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] is None + # Aliases should include the container's short-id (but it will be removed + # in API v1.45). + assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] == [attrs["Id"][:12]] assert (attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] is None)