Skip to content

Commit fd1b5bb

Browse files
constantiniusandrewshie-sentry
authored andcommitted
test(analytics): add additional test helper (#95429)
1 parent 8f5b647 commit fd1b5bb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/sentry/testutils/helpers/analytics.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ def assert_last_analytics_event(
6363
)
6464

6565

66+
def assert_any_analytics_event(
67+
mock_record: MagicMock,
68+
expected_event: Event,
69+
check_uuid: bool = False,
70+
check_datetime: bool = False,
71+
exclude_fields: list[str] | None = None,
72+
):
73+
recorded_events = [call.args[0] for call in mock_record.call_args_list]
74+
for recorded_event in recorded_events:
75+
try:
76+
assert_event_equal(
77+
expected_event, recorded_event, check_uuid, check_datetime, exclude_fields
78+
)
79+
return
80+
except AssertionError:
81+
pass
82+
83+
raise AssertionError(f"Event {expected_event} not found")
84+
85+
6686
@contextlib.contextmanager
6787
def assert_analytics_events(
6888
expected_events: list[Event],

0 commit comments

Comments
 (0)