Skip to content

Commit

Permalink
Add two redact operation test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
TamiTakamiya committed Jan 20, 2025
1 parent 09ed9d9 commit ca7b364
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ansible_ai_connect/ai/api/utils/tests/test_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ca7b364

Please sign in to comment.