Skip to content

ref: improve grouphash_metadata test #82101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions tests/sentry/grouping/test_grouphash_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

from typing import cast
from unittest.mock import MagicMock, patch
from unittest.mock import Mock, patch

import pytest

Expand All @@ -17,6 +16,7 @@
from sentry.models.grouphashmetadata import GroupHashMetadata, HashBasis
from sentry.models.project import Project
from sentry.projectoptions.defaults import DEFAULT_GROUPING_CONFIG
from sentry.testutils.helpers.options import override_options
from sentry.testutils.pytest.fixtures import InstaSnapshotter, django_db_all
from tests.sentry.grouping import (
GROUPING_INPUTS_DIR,
Expand All @@ -27,15 +27,11 @@
with_grouping_inputs,
)


class DummyProject:
id: int = 11211231


dummy_project = cast(Project, DummyProject())
dummy_project = Mock(id=11211231)


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

# This ensures we won't try to touch the DB when getting event variants
event.project = None # type: ignore[assignment]
event.project = dummy_project

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

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