From ca7b3648be348408cd097c8de6c5bd267d7f1a91 Mon Sep 17 00:00:00 2001 From: Tami Takamiya Date: Mon, 20 Jan 2025 14:53:37 -0500 Subject: [PATCH] Add two redact operation test cases. --- .../ai/api/utils/tests/test_segment.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ansible_ai_connect/ai/api/utils/tests/test_segment.py b/ansible_ai_connect/ai/api/utils/tests/test_segment.py index 4f49f64fb..7c2d549f2 100644 --- a/ansible_ai_connect/ai/api/utils/tests/test_segment.py +++ b/ansible_ai_connect/ai/api/utils/tests/test_segment.py @@ -270,6 +270,48 @@ def test_redact_trialExpired_response_data(self, *args): redact_seated_users_data(test_data, ALLOW_LIST["trialExpired"]), expected_result ) + def test_redact_chat_operational_event(self, *args): + test_data = { + "type": "chatOperationalEvent", + "modelName": "org-model-id", + "rh_user_has_seat": True, + "rh_user_org_id": 101, + "anything": "whatever", + } + + expected_result = { + "type": "chatOperationalEvent", + "modelName": "org-model-id", + "rh_user_has_seat": True, + "rh_user_org_id": 101, + "anything": "whatever", # Any properties won't be redacted for chatOperationalEvent + } + + self.assertEqual( + redact_seated_users_data(test_data, ALLOW_LIST["chatOperationalEvent"]), expected_result + ) + + def test_redact_chat_feedback_event(self, *args): + test_data = { + "type": "chatFeedbackEvent", + "modelName": "org-model-id", + "rh_user_has_seat": True, + "rh_user_org_id": 101, + "anything": "whatever", + } + + expected_result = { + "type": "chatFeedbackEvent", + "modelName": "org-model-id", + "rh_user_has_seat": True, + "rh_user_org_id": 101, + "anything": "whatever", # Any properties won't be redacted for chatFeedbackEvent + } + + self.assertEqual( + redact_seated_users_data(test_data, ALLOW_LIST["chatFeedbackEvent"]), expected_result + ) + @mock.patch("ansible_ai_connect.ai.api.utils.segment.analytics.group") @override_settings(SEGMENT_WRITE_KEY="DUMMY_KEY_VALUE") def test_send_segment_group(self, group_method):