Skip to content

Commit 6b9d61c

Browse files
asottile-sentryevanh
authored andcommitted
ref: improve grouphash_metadata test (#82101)
this test still adds a full minute and a half to the testsuite but at least now it doesn't inject nullability into events! <!-- Describe your PR here. -->
1 parent c61b83c commit 6b9d61c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Diff for: tests/sentry/grouping/test_grouphash_metadata.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import cast
4-
from unittest.mock import MagicMock, patch
3+
from unittest.mock import Mock, patch
54

65
import pytest
76

@@ -17,6 +16,7 @@
1716
from sentry.models.grouphashmetadata import GroupHashMetadata, HashBasis
1817
from sentry.models.project import Project
1918
from sentry.projectoptions.defaults import DEFAULT_GROUPING_CONFIG
19+
from sentry.testutils.helpers.options import override_options
2020
from sentry.testutils.pytest.fixtures import InstaSnapshotter, django_db_all
2121
from tests.sentry.grouping import (
2222
GROUPING_INPUTS_DIR,
@@ -27,15 +27,11 @@
2727
with_grouping_inputs,
2828
)
2929

30-
31-
class DummyProject:
32-
id: int = 11211231
33-
34-
35-
dummy_project = cast(Project, DummyProject())
30+
dummy_project = Mock(id=11211231)
3631

3732

3833
@with_grouping_inputs("grouping_input", GROUPING_INPUTS_DIR)
34+
@override_options({"grouping.experiments.parameterization.uniq_id": 0})
3935
@pytest.mark.parametrize(
4036
"config_name",
4137
set(CONFIGURATIONS.keys()) - {DEFAULT_GROUPING_CONFIG},
@@ -55,7 +51,7 @@ def test_hash_basis_with_legacy_configs(
5551
event = grouping_input.create_event(config_name, use_full_ingest_pipeline=False)
5652

5753
# 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
5955

6056
_assert_and_snapshot_results(event, config_name, grouping_input.filename, insta_snapshot)
6157

@@ -120,7 +116,7 @@ def test_unknown_hash_basis(
120116
with patch.object(
121117
event,
122118
"get_grouping_variants",
123-
new=MagicMock(return_value={"dogs": ComponentVariant(component, StrategyConfiguration())}),
119+
return_value={"dogs": ComponentVariant(component, StrategyConfiguration())},
124120
):
125121
# Overrride the input filename since there isn't a real input which will generate the mock
126122
# variants above, but we still want the snapshot.

0 commit comments

Comments
 (0)