From ac0fee80e037111c45705b28c64157f8bbce3fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Malinowski?= <56644812+stan-dot@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:20:25 +0100 Subject: [PATCH] rename the messaging_template in the service (#673) --- src/blueapi/service/interface.py | 10 +++++----- tests/unit_tests/service/test_interface.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blueapi/service/interface.py b/src/blueapi/service/interface.py index 914639c62..e9217bce3 100644 --- a/src/blueapi/service/interface.py +++ b/src/blueapi/service/interface.py @@ -49,7 +49,7 @@ def worker() -> TaskWorker: @lru_cache -def messaging_template() -> StompClient | None: +def stomp_client() -> StompClient | None: stomp_config = config().stomp if stomp_config is not None: template = StompClient.for_broker( @@ -83,16 +83,16 @@ def setup(config: ApplicationConfig) -> None: logging.basicConfig(level=config.logging.level) worker() - messaging_template() + stomp_client() def teardown() -> None: worker().stop() - if (template := messaging_template()) is not None: + if (template := stomp_client()) is not None: template.disconnect() context.cache_clear() worker.cache_clear() - messaging_template.cache_clear() + stomp_client.cache_clear() def _publish_event_streams( @@ -104,7 +104,7 @@ def _publish_event_streams( def _publish_event_stream(stream: EventStream, destination: DestinationBase) -> None: def forward_message(event: Any, correlation_id: str | None) -> None: - if (template := messaging_template()) is not None: + if (template := stomp_client()) is not None: template.send(destination, event, None, correlation_id=correlation_id) stream.subscribe(forward_message) diff --git a/tests/unit_tests/service/test_interface.py b/tests/unit_tests/service/test_interface.py index 86dd2e5c1..36c6b69e9 100644 --- a/tests/unit_tests/service/test_interface.py +++ b/tests/unit_tests/service/test_interface.py @@ -288,4 +288,4 @@ def test_stomp_config(template: StompClient): "blueapi.service.interface.StompClient.for_broker", return_value=template ): interface.set_config(ApplicationConfig(stomp=StompConfig())) - assert interface.messaging_template() is not None + assert interface.stomp_client() is not None