1
1
from __future__ import annotations
2
2
3
- from typing import cast
4
- from unittest .mock import MagicMock , patch
3
+ from unittest .mock import Mock , patch
5
4
6
5
import pytest
7
6
17
16
from sentry .models .grouphashmetadata import GroupHashMetadata , HashBasis
18
17
from sentry .models .project import Project
19
18
from sentry .projectoptions .defaults import DEFAULT_GROUPING_CONFIG
19
+ from sentry .testutils .helpers .options import override_options
20
20
from sentry .testutils .pytest .fixtures import InstaSnapshotter , django_db_all
21
21
from tests .sentry .grouping import (
22
22
GROUPING_INPUTS_DIR ,
27
27
with_grouping_inputs ,
28
28
)
29
29
30
-
31
- class DummyProject :
32
- id : int = 11211231
33
-
34
-
35
- dummy_project = cast (Project , DummyProject ())
30
+ dummy_project = Mock (id = 11211231 )
36
31
37
32
38
33
@with_grouping_inputs ("grouping_input" , GROUPING_INPUTS_DIR )
34
+ @override_options ({"grouping.experiments.parameterization.uniq_id" : 0 })
39
35
@pytest .mark .parametrize (
40
36
"config_name" ,
41
37
set (CONFIGURATIONS .keys ()) - {DEFAULT_GROUPING_CONFIG },
@@ -55,7 +51,7 @@ def test_hash_basis_with_legacy_configs(
55
51
event = grouping_input .create_event (config_name , use_full_ingest_pipeline = False )
56
52
57
53
# This ensures we won't try to touch the DB when getting event variants
58
- event .project = None # type: ignore[assignment]
54
+ event .project = dummy_project
59
55
60
56
_assert_and_snapshot_results (event , config_name , grouping_input .filename , insta_snapshot )
61
57
@@ -120,7 +116,7 @@ def test_unknown_hash_basis(
120
116
with patch .object (
121
117
event ,
122
118
"get_grouping_variants" ,
123
- new = MagicMock ( return_value = {"dogs" : ComponentVariant (component , StrategyConfiguration ())}) ,
119
+ return_value = {"dogs" : ComponentVariant (component , StrategyConfiguration ())},
124
120
):
125
121
# Overrride the input filename since there isn't a real input which will generate the mock
126
122
# variants above, but we still want the snapshot.
0 commit comments