From 79f9afb4c2505f7e1c176e603397a963e6334fa4 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 3 Feb 2026 10:34:47 +0100 Subject: [PATCH] Fix port conflict tests for aiodocker 0.25.0 compatibility (#6519) The aiodocker 0.25.0 upgrade (PR #6448) changed how DockerError handles the message parameter. The library now extracts the message string from Docker API JSON responses before passing it to DockerError, rather than passing the entire dict. The port conflict detection tests were written before this change and incorrectly passed dicts to DockerError. This caused TypeErrors when the port conflict detection code tried to match err.message with a regex, expecting a string but receiving a dict. Update both test_addon_start_port_conflict_error and test_observer_start_port_conflict to pass message strings directly, matching the real aiodocker 0.25.0 behavior. Co-authored-by: Claude Sonnet 4.5 --- tests/addons/test_addon.py | 4 +--- tests/plugins/test_observer.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/addons/test_addon.py b/tests/addons/test_addon.py index b2cb6202b..6dae0bdd4 100644 --- a/tests/addons/test_addon.py +++ b/tests/addons/test_addon.py @@ -1017,9 +1017,7 @@ async def test_addon_start_port_conflict_error( install_addon_ssh.data["image"] = "test/amd64-addon-ssh" coresys.docker.containers.create.return_value.start.side_effect = aiodocker.DockerError( HTTPStatus.INTERNAL_SERVER_ERROR, - { - "message": "failed to set up container networking: driver failed programming external connectivity on endpoint addon_local_ssh (ea4d0fdaa72cf86f2c9199a04208e3eaf0c5a0d6fd34b3c7f4fab2daadb1f3a9): failed to bind host port for 0.0.0.0:2222:172.30.33.4:22/tcp: address already in use" - }, + "failed to set up container networking: driver failed programming external connectivity on endpoint addon_local_ssh (ea4d0fdaa72cf86f2c9199a04208e3eaf0c5a0d6fd34b3c7f4fab2daadb1f3a9): failed to bind host port for 0.0.0.0:2222:172.30.33.4:22/tcp: address already in use", ) await install_addon_ssh.load() diff --git a/tests/plugins/test_observer.py b/tests/plugins/test_observer.py index a8f182b81..3b1b9f9bd 100644 --- a/tests/plugins/test_observer.py +++ b/tests/plugins/test_observer.py @@ -16,9 +16,7 @@ async def test_observer_start_port_conflict( """Test port conflict error when trying to start observer.""" coresys.docker.containers.create.return_value.start.side_effect = aiodocker.DockerError( HTTPStatus.INTERNAL_SERVER_ERROR, - { - "message": "failed to set up container networking: driver failed programming external connectivity on endpoint hassio_observer (ea4d0fdaa72cf86f2c9199a04208e3eaf0c5a0d6fd34b3c7f4fab2daadb1f3a9): failed to bind host port for 0.0.0.0:4357:172.30.33.4:80/tcp: address already in use" - }, + "failed to set up container networking: driver failed programming external connectivity on endpoint hassio_observer (ea4d0fdaa72cf86f2c9199a04208e3eaf0c5a0d6fd34b3c7f4fab2daadb1f3a9): failed to bind host port for 0.0.0.0:4357:172.30.33.4:80/tcp: address already in use", ) await coresys.plugins.observer.load()