From c6902309307be439cf42f330ba4602db4dc56e98 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 4 May 2023 00:28:50 +0200 Subject: [PATCH] An `AssistantEvent` should not fail initialization if the assistant integration isn't found. --- platypush/message/event/assistant/__init__.py | 15 ++++++--------- tests/test_event_parse.py | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 2047c1a62d..1ca2049e64 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -17,15 +17,12 @@ class AssistantEvent(Event): if assistant: self._assistant = assistant else: - self._assistant = get_backend('assistant.google') - - if not self._assistant: - self._assistant = get_plugin('assistant.google.pushtotalk') - - if not self._assistant: - self.logger.warning( - 'Assistant plugin/backend not configured/initialized' - ) + try: + self._assistant = get_backend('assistant.google') + if not self._assistant: + self._assistant = get_plugin('assistant.google.pushtotalk') + except Exception as e: + self.logger.debug('Could not initialize the assistant component: %s', e) self._assistant = None diff --git a/tests/test_event_parse.py b/tests/test_event_parse.py index dfb45e4496..443336f795 100644 --- a/tests/test_event_parse.py +++ b/tests/test_event_parse.py @@ -82,7 +82,7 @@ def test_speech_recognized_event_parse(): assert 'answer' in result.parsed_args assert result.parsed_args['answer'] == '42' - event = PingEvent(phrase="what is not the answer? 43") + event = SpeechRecognizedEvent(phrase="what is not the answer? 43") result = event.matches_condition(condition) assert not result.is_match