From 343f4c3e2d6fd3580fb76150c26350d521cf5698 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Thu, 19 Dec 2024 11:51:06 -0300 Subject: [PATCH] The connect_signals was triggered the API request twice The connect_signals method in our QueryContext was triggering the API requests twice (as expected), but this is not the behavior we want. This patch removes this functionality. --- command_line_assistant/dbus/interfaces.py | 12 +++--------- tests/dbus/test_interfaces.py | 6 ------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/command_line_assistant/dbus/interfaces.py b/command_line_assistant/dbus/interfaces.py index e11b2a3..ad1ed28 100644 --- a/command_line_assistant/dbus/interfaces.py +++ b/command_line_assistant/dbus/interfaces.py @@ -16,21 +16,15 @@ class QueryInterface(InterfaceTemplate): """The DBus interface of a query.""" - def connect_signals(self) -> None: - """Connect the signals.""" - # Watch for property changes based on the query_changed method. - self.watch_property("RetrieveAnswer", self.implementation.query_changed) - @property def RetrieveAnswer(self) -> Structure: """This method is mainly called by the client to retrieve it's answer.""" - output = Message() llm_response = submit( self.implementation.query.message, self.implementation.config ) - print("llm_response", llm_response) - output.message = llm_response - return Message.to_structure(output) + message = Message() + message.message = llm_response + return Message.to_structure(message) @emits_properties_changed def ProcessQuery(self, query: Structure) -> None: diff --git a/tests/dbus/test_interfaces.py b/tests/dbus/test_interfaces.py index 86805cd..cb24f79 100644 --- a/tests/dbus/test_interfaces.py +++ b/tests/dbus/test_interfaces.py @@ -28,12 +28,6 @@ def query_interface(mock_implementation): class TestQueryInterface: - def test_connect_signals(self, query_interface, mock_implementation): - query_interface.connect_signals() - query_interface.watch_property.assert_called_once_with( - "RetrieveAnswer", mock_implementation.query_changed - ) - @patch("command_line_assistant.dbus.interfaces.submit") def test_retrieve_answer_success( self, mock_submit, query_interface, mock_implementation