Skip to content

Commit 32de56d

Browse files
authored
tests(deletion): Events after group deletion create new groups (#95976)
This is the test missing from #93541 that would have prevented the regression.
1 parent c7a6039 commit 32de56d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/snuba/api/endpoints/test_project_group_index.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,3 +1657,32 @@ def test_audit_log_even_if_exception_raised(
16571657

16581658
# They have been marked as pending deletion but the exception prevented their complete deletion
16591659
assert Group.objects.get(id=group1.id).status == GroupStatus.PENDING_DELETION
1660+
1661+
def test_new_event_for_pending_deletion_group_creates_new_group(self):
1662+
"""Test that after deleting a group, new events with the same fingerprint create a new group."""
1663+
data = {
1664+
"fingerprint": ["test-fingerprint"],
1665+
"timestamp": timezone.now().isoformat(),
1666+
}
1667+
# Store an event to create a group
1668+
event1 = self.store_event(data=data, project_id=self.project.id)
1669+
original_group = event1.group
1670+
original_group_id = original_group.id
1671+
1672+
# First we call the endpoint which will mark the group as pending deletion & delete the hashes
1673+
self.login_as(user=self.user)
1674+
1675+
# Since we're calling without self.tasks(), the group will not be deleted
1676+
# We're emulating the delay between the endpoint being called and the task being executed
1677+
response = self.client.delete(f"{self.path}?id={original_group_id}", format="json")
1678+
assert response.status_code == 204
1679+
1680+
assert Group.objects.get(id=original_group_id).status == GroupStatus.PENDING_DELETION
1681+
assert not GroupHash.objects.filter(group_id=original_group_id).exists()
1682+
1683+
# Since the group hash has been deleted, a new group will be created
1684+
event2 = self.store_event(data=data, project_id=self.project.id)
1685+
# Verify a new group is created with a different ID
1686+
new_group = event2.group
1687+
assert new_group.id != original_group_id
1688+
assert Group.objects.filter(id=new_group.id).exists()

0 commit comments

Comments
 (0)