MCPcopy Index your code
hub / github.com/getsentry/sentry / test_basic

Function test_basic

tests/sentry/tasks/test_reprocessing2.py:97–202  ·  view source on GitHub ↗
(
    task_runner,
    default_project,
    change_groups,
    reset_snuba,
    process_and_save,
    register_event_preprocessor,
    django_cache,
)

Source from the content-addressed store, hash-verified

95@pytest.mark.snuba
96@pytest.mark.parametrize("change_groups", (True, False), ids=("new_group", "same_group"))
97def test_basic(
98 task_runner,
99 default_project,
100 change_groups,
101 reset_snuba,
102 process_and_save,
103 register_event_preprocessor,
104 django_cache,
105):
106 from sentry import eventstream
107
108 tombstone_calls = []
109 old_tombstone_fn = eventstream.backend.tombstone_events_unsafe
110
111 def tombstone_called(*args, **kwargs):
112 tombstone_calls.append((args, kwargs))
113 old_tombstone_fn(*args, **kwargs)
114
115 with mock.patch("sentry.eventstream.backend.tombstone_events_unsafe", tombstone_called):
116 abs_count = 0
117
118 @register_event_preprocessor
119 def event_preprocessor(data):
120 nonlocal abs_count
121
122 tags = data.setdefault("tags", [])
123 assert all(not x or x[0] != "processing_counter" for x in tags)
124 tags.append(("processing_counter", f"x{abs_count}"))
125 abs_count += 1
126
127 if change_groups:
128 data["fingerprint"] = [uuid.uuid4().hex]
129 else:
130 data["fingerprint"] = ["foo"]
131
132 return data
133
134 event_id = process_and_save({"tags": [["key1", "value"], None, ["key2", "value"]]})
135
136 def get_event_by_processing_counter(n: str) -> list[Event]:
137 return list(
138 eventstore.backend.get_events(
139 eventstore.Filter(
140 project_ids=[default_project.id],
141 conditions=[["tags[processing_counter]", "=", n]],
142 ),
143 tenant_ids={"organization_id": 1234, "referrer": "eventstore.get_events"},
144 )
145 )
146
147 event = eventstore.backend.get_event_by_id(
148 default_project.id,
149 event_id,
150 tenant_ids={"organization_id": 1234, "referrer": "eventstore.get_events"},
151 )
152 assert event is not None
153 assert event.get_tag("processing_counter") == "x0"
154 assert not event.data.get("errors")

Callers

nothing calls this directly

Calls 13

BurstTaskRunnerFunction · 0.90
reprocess_groupFunction · 0.90
is_group_finishedFunction · 0.90
process_and_saveFunction · 0.85
get_tagMethod · 0.80
get_hashesMethod · 0.80
get_primary_hashMethod · 0.80
getMethod · 0.65
patchMethod · 0.45
get_event_by_idMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected