From 05622deccff4d0e0725185c38283cc72ad02259e Mon Sep 17 00:00:00 2001 From: raul-marquez-csa Date: Thu, 16 Nov 2023 03:59:49 -0800 Subject: [PATCH 1/4] Updates MessageTypeEnum to include options and message types --- app/constants/websockets_constants.py | 2 ++ .../user_prompts/test_options_select_user_prompts.py | 2 +- app/user_prompt_support/user_prompt_manager.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/constants/websockets_constants.py b/app/constants/websockets_constants.py index c6d16652..11bb07f8 100644 --- a/app/constants/websockets_constants.py +++ b/app/constants/websockets_constants.py @@ -25,6 +25,8 @@ # Enum Keys for different types of messages currently supported by the tool class MessageTypeEnum(str, Enum): PROMPT_REQUEST = "prompt_request" + OPTIONS_REQUEST = "options_request" + MESSAGE_REQUEST = "message_request" PROMPT_RESPONSE = "prompt_response" TEST_UPDATE = "test_update" TIME_OUT_NOTIFICATION = "time_out_notification" diff --git a/app/tests/user_prompts/test_options_select_user_prompts.py b/app/tests/user_prompts/test_options_select_user_prompts.py index 4034edda..666640be 100644 --- a/app/tests/user_prompts/test_options_select_user_prompts.py +++ b/app/tests/user_prompts/test_options_select_user_prompts.py @@ -298,7 +298,7 @@ def __expected_response_dict_cancelled() -> Dict[str, Any]: def __expected_prompt_dict(timeout: int = 2, message_id: int = 1) -> Dict[str, Any]: return { - MessageKeysEnum.TYPE: MessageTypeEnum.PROMPT_REQUEST, + MessageKeysEnum.TYPE: MessageTypeEnum.OPTIONS_REQUEST, MessageKeysEnum.PAYLOAD: { OPTIONS_KEY: test_options, TIMEOUT_KEY: timeout, diff --git a/app/user_prompt_support/user_prompt_manager.py b/app/user_prompt_support/user_prompt_manager.py index ba152fae..e1f20654 100644 --- a/app/user_prompt_support/user_prompt_manager.py +++ b/app/user_prompt_support/user_prompt_manager.py @@ -50,6 +50,15 @@ def __init__(self, prompt: PromptRequest, message_id: int) -> None: def as_dictionary(self) -> Dict[MessageKeysEnum, Any]: prompt_dict = self.prompt.dict() prompt_dict[MESSAGE_ID_KEY] = self.message_id + message_type = MessageTypeEnum.PROMPT_REQUEST + + # Check if options exist + if "options" in prompt_dict: + if prompt_dict["options"]: + message_type = MessageTypeEnum.OPTIONS_REQUEST + else: + message_type = MessageTypeEnum.MESSAGE_REQUEST + message_dict = { MessageKeysEnum.TYPE: MessageTypeEnum.PROMPT_REQUEST, MessageKeysEnum.PAYLOAD: prompt_dict, From 849bb958031d38f320bdb06b2c22b337f1b52e09 Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:16:18 -0300 Subject: [PATCH 2/4] Update app/user_prompt_support/user_prompt_manager.py Co-authored-by: antonio-amjr <116589331+antonio-amjr@users.noreply.github.com> --- app/user_prompt_support/user_prompt_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/user_prompt_support/user_prompt_manager.py b/app/user_prompt_support/user_prompt_manager.py index e1f20654..f1f54f2c 100644 --- a/app/user_prompt_support/user_prompt_manager.py +++ b/app/user_prompt_support/user_prompt_manager.py @@ -60,7 +60,7 @@ def as_dictionary(self) -> Dict[MessageKeysEnum, Any]: message_type = MessageTypeEnum.MESSAGE_REQUEST message_dict = { - MessageKeysEnum.TYPE: MessageTypeEnum.PROMPT_REQUEST, + MessageKeysEnum.TYPE: message_type, MessageKeysEnum.PAYLOAD: prompt_dict, } return message_dict From 9a5023dd73b81d88879a660b58779440fa01d0ab Mon Sep 17 00:00:00 2001 From: Romulo Quidute Filho <116586593+rquidute@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:16:25 -0300 Subject: [PATCH 3/4] Update app/constants/websockets_constants.py Co-authored-by: hiltonlima <116589806+hiltonlima@users.noreply.github.com> --- app/constants/websockets_constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/constants/websockets_constants.py b/app/constants/websockets_constants.py index 11bb07f8..43890503 100644 --- a/app/constants/websockets_constants.py +++ b/app/constants/websockets_constants.py @@ -26,7 +26,7 @@ class MessageTypeEnum(str, Enum): PROMPT_REQUEST = "prompt_request" OPTIONS_REQUEST = "options_request" - MESSAGE_REQUEST = "message_request" + MESSAGE_REQUEST = "message_request" PROMPT_RESPONSE = "prompt_response" TEST_UPDATE = "test_update" TIME_OUT_NOTIFICATION = "time_out_notification" From ff8afdb2b6c91097482f97516e8c0037c9b72b43 Mon Sep 17 00:00:00 2001 From: Carolina Lopes <116589288+ccruzagralopes@users.noreply.github.com> Date: Fri, 17 Nov 2023 16:18:56 -0300 Subject: [PATCH 4/4] Update app/user_prompt_support/user_prompt_manager.py --- app/user_prompt_support/user_prompt_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/user_prompt_support/user_prompt_manager.py b/app/user_prompt_support/user_prompt_manager.py index f1f54f2c..fbb0e48b 100644 --- a/app/user_prompt_support/user_prompt_manager.py +++ b/app/user_prompt_support/user_prompt_manager.py @@ -58,7 +58,6 @@ def as_dictionary(self) -> Dict[MessageKeysEnum, Any]: message_type = MessageTypeEnum.OPTIONS_REQUEST else: message_type = MessageTypeEnum.MESSAGE_REQUEST - message_dict = { MessageKeysEnum.TYPE: message_type, MessageKeysEnum.PAYLOAD: prompt_dict,