@@ -67,31 +67,36 @@ def test_create_and_store_occurrence(self) -> None:
6767 assert len (result ["data" ]) == 1
6868 assert result ["data" ][0 ]["count()" ] == 1
6969
70- def test_occurrence_type_filtering (self ) -> None :
70+ def test_occurrence_category_filtering (self ) -> None :
7171 group_error = self .create_group (project = self .project )
7272 group_generic = self .create_group (project = self .project )
7373
74+ # Error events have no occurrence_id
7475 error_occurrence = self .create_eap_occurrence (
7576 group_id = group_error .id ,
76- occurrence_type = "error" ,
7777 )
78+ # Issue platform events have an occurrence_id
7879 generic_occurrence = self .create_eap_occurrence (
7980 group_id = group_generic .id ,
80- occurrence_type = "generic" ,
81+ occurrence_id = uuid4 (). hex ,
8182 )
8283 self .store_eap_items ([error_occurrence , generic_occurrence ])
8384
84- # OccurrenceCategory.ERROR filters for type != "generic"
85+ # OccurrenceCategory.ERROR filters for items without occurrence_id
8586 error_result = self ._query_occurrences (
87+ selected_columns = ["group_id" , "count()" ],
8688 occurrence_category = OccurrenceCategory .ERROR ,
8789 )
8890 assert error_result ["data" ][0 ]["count()" ] == 1
91+ assert error_result ["data" ][0 ]["group_id" ] == group_error .id
8992
90- # OccurrenceCategory.GENERIC filters for type == "generic"
93+ # OccurrenceCategory.ISSUE_PLATFORM filters for items with occurrence_id
9194 generic_result = self ._query_occurrences (
92- occurrence_category = OccurrenceCategory .GENERIC ,
95+ selected_columns = ["group_id" , "count()" ],
96+ occurrence_category = OccurrenceCategory .ISSUE_PLATFORM ,
9397 )
9498 assert generic_result ["data" ][0 ]["count()" ] == 1
99+ assert generic_result ["data" ][0 ]["group_id" ] == group_generic .id
95100
96101 # No category filter returns both
97102 all_result = self ._query_occurrences ()
@@ -225,11 +230,13 @@ def test_filters_by_occurrence_category(self) -> None:
225230 group = self .create_group (project = self .project )
226231 self .store_eap_items (
227232 [
228- self .create_eap_occurrence (group_id = group .id , occurrence_type = "error" ),
229- self .create_eap_occurrence (group_id = group .id , occurrence_type = "error" ),
230- self .create_eap_occurrence (group_id = group .id , occurrence_type = "error" ),
231- self .create_eap_occurrence (group_id = group .id , occurrence_type = "generic" ),
232- self .create_eap_occurrence (group_id = group .id , occurrence_type = "generic" ),
233+ # Error events: no occurrence_id
234+ self .create_eap_occurrence (group_id = group .id ),
235+ self .create_eap_occurrence (group_id = group .id ),
236+ self .create_eap_occurrence (group_id = group .id ),
237+ # Generic events: have occurrence_id
238+ self .create_eap_occurrence (group_id = group .id , occurrence_id = uuid4 ().hex ),
239+ self .create_eap_occurrence (group_id = group .id , occurrence_id = uuid4 ().hex ),
233240 ]
234241 )
235242
@@ -247,7 +254,7 @@ def test_filters_by_occurrence_category(self) -> None:
247254 start = self .start ,
248255 end = self .end ,
249256 referrer = self .referrer ,
250- occurrence_category = OccurrenceCategory .GENERIC ,
257+ occurrence_category = OccurrenceCategory .ISSUE_PLATFORM ,
251258 )
252259
253260 assert error_count == 3
@@ -282,14 +289,12 @@ def test_counts_grouped_by_trace_ids_with_occurrence_category(self) -> None:
282289 trace_id = uuid4 ().hex
283290 self .store_eap_items (
284291 [
292+ # Error events: no occurrence_id
293+ self .create_eap_occurrence (group_id = group .id , trace_id = trace_id ),
294+ self .create_eap_occurrence (group_id = group .id , trace_id = trace_id ),
295+ # Generic event: has occurrence_id
285296 self .create_eap_occurrence (
286- group_id = group .id , trace_id = trace_id , occurrence_type = "error"
287- ),
288- self .create_eap_occurrence (
289- group_id = group .id , trace_id = trace_id , occurrence_type = "error"
290- ),
291- self .create_eap_occurrence (
292- group_id = group .id , trace_id = trace_id , occurrence_type = "generic"
297+ group_id = group .id , trace_id = trace_id , occurrence_id = uuid4 ().hex
293298 ),
294299 ]
295300 )
@@ -310,7 +315,7 @@ def test_counts_grouped_by_trace_ids_with_occurrence_category(self) -> None:
310315 snuba_params = snuba_params ,
311316 trace_ids = [trace_id ],
312317 referrer = self .referrer ,
313- occurrence_category = OccurrenceCategory .GENERIC ,
318+ occurrence_category = OccurrenceCategory .ISSUE_PLATFORM ,
314319 )
315320
316321 assert grouped_errors == {trace_id : 2 }
0 commit comments