From 05c6a3bc2c641fdd081740cd211794d9b7d7767b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Doumouro?= Date: Mon, 8 Jul 2024 16:48:35 +0200 Subject: [PATCH] chore: fix AMQPWorkerConfig.broker_url --- icij-worker/icij_worker/tests/worker/test_amqp.py | 9 +++++++++ icij-worker/icij_worker/worker/amqp.py | 4 ++-- icij-worker/pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/icij-worker/icij_worker/tests/worker/test_amqp.py b/icij-worker/icij_worker/tests/worker/test_amqp.py index 8a96bcc1..0feff38b 100644 --- a/icij-worker/icij_worker/tests/worker/test_amqp.py +++ b/icij-worker/icij_worker/tests/worker/test_amqp.py @@ -417,3 +417,12 @@ async def test_publish_result( received_result = TaskResult.parse_raw(message.body) break assert received_result == result + + +async def test_amqp_config_uri(): + # Given + config = AMQPWorkerConfig() + # When + url = config.broker_url + # Then + assert url == "amqp://127.0.0.1:5672/%2F" diff --git a/icij-worker/icij_worker/worker/amqp.py b/icij-worker/icij_worker/worker/amqp.py index 373ab32d..f66ecddc 100644 --- a/icij-worker/icij_worker/worker/amqp.py +++ b/icij-worker/icij_worker/worker/amqp.py @@ -62,8 +62,8 @@ def broker_url(self) -> str: if amqp_userinfo: amqp_userinfo += "@" amqp_authority = ( - f"{amqp_userinfo}{self.rabbitmq_host}" - f"{f':{self.rabbitmq_port}' if self.rabbitmq_port else ''}" + f"{amqp_userinfo or ''}{self.rabbitmq_host}" + f"{f':{self.rabbitmq_port}' or ''}" ) amqp_uri = f"amqp://{amqp_authority}" if self.rabbitmq_vhost is not None: diff --git a/icij-worker/pyproject.toml b/icij-worker/pyproject.toml index c7c772a5..bbb49aeb 100644 --- a/icij-worker/pyproject.toml +++ b/icij-worker/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "icij-worker" -version = "0.3.0" +version = "0.3.1" description = "Create asynchronous tasks from Python functions" authors = [ "Clément Doumouro ",