17
17
from sentry .models .grouphash import GroupHash
18
18
from sentry .models .project import Project
19
19
from sentry .testutils .helpers .eventprocessing import save_new_event
20
+ from sentry .testutils .helpers .features import Feature
20
21
from sentry .testutils .pytest .fixtures import django_db_all
21
22
from sentry .testutils .pytest .mocking import capture_return_values
22
23
from sentry .testutils .skips import requires_snuba
@@ -121,6 +122,7 @@ def get_results_from_saving_event(
121
122
secondary_config : str ,
122
123
in_transition : bool ,
123
124
existing_group_id : int | None = None ,
125
+ new_logic_enabled : bool = False ,
124
126
):
125
127
# Slightly gross (and with even grosser auto-formatting), but it saves having to do a bunch of
126
128
# `x if y else None` below
@@ -138,7 +140,10 @@ def get_results_from_saving_event(
138
140
139
141
return_values : dict [str , list [Any ]] = {}
140
142
141
- with patch_grouping_helpers (return_values ) as spies :
143
+ with (
144
+ patch_grouping_helpers (return_values ) as spies ,
145
+ Feature ({"organizations:grouping-suppress-unnecessary-secondary-hash" : new_logic_enabled }),
146
+ ):
142
147
calculate_secondary_hash_spy = spies ["_calculate_secondary_hash" ]
143
148
create_group_spy = spies ["_create_group" ]
144
149
calculate_primary_hash_spy = spies ["_calculate_primary_hash" ]
@@ -227,7 +232,13 @@ def get_results_from_saving_event(
227
232
@pytest .mark .parametrize (
228
233
"in_transition" , (True , False ), ids = (" in_transition: True " , " in_transition: False " )
229
234
)
235
+ @pytest .mark .parametrize (
236
+ "new_logic_enabled" ,
237
+ (True , False ),
238
+ ids = (" new_logic_enabled: True " , " new_logic_enabled: False " ),
239
+ )
230
240
def test_new_group (
241
+ new_logic_enabled : bool ,
231
242
in_transition : bool ,
232
243
default_project : Project ,
233
244
):
@@ -240,6 +251,7 @@ def test_new_group(
240
251
primary_config = NEWSTYLE_CONFIG ,
241
252
secondary_config = LEGACY_CONFIG ,
242
253
in_transition = in_transition ,
254
+ new_logic_enabled = new_logic_enabled ,
243
255
)
244
256
245
257
if in_transition :
@@ -279,7 +291,13 @@ def test_new_group(
279
291
@pytest .mark .parametrize (
280
292
"in_transition" , (True , False ), ids = (" in_transition: True " , " in_transition: False " )
281
293
)
294
+ @pytest .mark .parametrize (
295
+ "new_logic_enabled" ,
296
+ (True , False ),
297
+ ids = (" new_logic_enabled: True " , " new_logic_enabled: False " ),
298
+ )
282
299
def test_existing_group_no_new_hash (
300
+ new_logic_enabled : bool ,
283
301
in_transition : bool ,
284
302
default_project : Project ,
285
303
):
@@ -297,6 +315,7 @@ def test_existing_group_no_new_hash(
297
315
secondary_config = LEGACY_CONFIG ,
298
316
in_transition = in_transition ,
299
317
existing_group_id = existing_event .group_id ,
318
+ new_logic_enabled = new_logic_enabled ,
300
319
)
301
320
302
321
if in_transition :
@@ -334,13 +353,19 @@ def test_existing_group_no_new_hash(
334
353
@pytest .mark .parametrize (
335
354
"in_transition" , (True , False ), ids = (" in_transition: True " , " in_transition: False " )
336
355
)
356
+ @pytest .mark .parametrize (
357
+ "new_logic_enabled" ,
358
+ (True , False ),
359
+ ids = (" new_logic_enabled: True " , " new_logic_enabled: False " ),
360
+ )
337
361
@pytest .mark .parametrize (
338
362
"secondary_hash_exists" ,
339
363
(True , False ),
340
364
ids = (" secondary_hash_exists: True " , " secondary_hash_exists: False " ),
341
365
)
342
366
def test_existing_group_new_hash_exists (
343
367
secondary_hash_exists : bool ,
368
+ new_logic_enabled : bool ,
344
369
in_transition : bool ,
345
370
default_project : Project ,
346
371
):
@@ -375,6 +400,7 @@ def test_existing_group_new_hash_exists(
375
400
secondary_config = LEGACY_CONFIG ,
376
401
in_transition = in_transition ,
377
402
existing_group_id = existing_event .group_id ,
403
+ new_logic_enabled = new_logic_enabled ,
378
404
)
379
405
380
406
if in_transition :
0 commit comments