|
10 | 10 | from mock import patch, Mock |
11 | 11 |
|
12 | 12 | from sentry.models import ( |
13 | | - Activity, ApiToken, Event, EventMapping, ExternalIssue, Group, GroupAssignee, |
14 | | - GroupBookmark, GroupHash, GroupLink, GroupSeen, GroupShare, GroupSnooze, |
15 | | - GroupStatus, GroupResolution, GroupSubscription, GroupTombstone, Integration, |
| 13 | + Activity, ApiToken, ExternalIssue, Group, GroupAssignee, GroupBookmark, |
| 14 | + GroupHash, GroupLink, GroupSeen, GroupShare, GroupSnooze, GroupStatus, |
| 15 | + GroupResolution, GroupSubscription, GroupTombstone, Integration, |
16 | 16 | OrganizationIntegration, UserOption, Release |
17 | 17 | ) |
18 | 18 | from sentry.testutils import APITestCase, SnubaTestCase |
@@ -209,22 +209,21 @@ def test_auto_resolved(self): |
209 | 209 | def test_lookup_by_event_id(self): |
210 | 210 | project = self.project |
211 | 211 | project.update_option('sentry:resolve_age', 1) |
212 | | - group = self.create_group(checksum='a' * 32) |
213 | | - self.create_group(checksum='b' * 32) |
214 | 212 | event_id = 'c' * 32 |
215 | | - Event.objects.create(project_id=self.project.id, event_id=event_id) |
216 | | - EventMapping.objects.create( |
217 | | - event_id=event_id, |
218 | | - project=group.project, |
219 | | - group=group, |
| 213 | + event = self.store_event( |
| 214 | + data={ |
| 215 | + 'event_id': event_id, |
| 216 | + 'timestamp': self.min_ago.isoformat()[:19], |
| 217 | + }, |
| 218 | + project_id=self.project.id |
220 | 219 | ) |
221 | 220 |
|
222 | 221 | self.login_as(user=self.user) |
223 | 222 |
|
224 | 223 | response = self.get_valid_response(query='c' * 32) |
225 | 224 | assert response['X-Sentry-Direct-Hit'] == '1' |
226 | 225 | assert len(response.data) == 1 |
227 | | - assert response.data[0]['id'] == six.text_type(group.id) |
| 226 | + assert response.data[0]['id'] == six.text_type(event.group.id) |
228 | 227 | assert response.data[0]['matchingEventId'] == event_id |
229 | 228 |
|
230 | 229 | def test_lookup_by_event_id_incorrect_project_id(self): |
@@ -257,20 +256,20 @@ def test_lookup_by_event_id_incorrect_project_id(self): |
257 | 256 | def test_lookup_by_event_id_with_whitespace(self): |
258 | 257 | project = self.project |
259 | 258 | project.update_option('sentry:resolve_age', 1) |
260 | | - group = self.create_group(checksum='a' * 32) |
261 | 259 | event_id = 'c' * 32 |
262 | | - self.create_group(checksum='b' * 32) |
263 | | - EventMapping.objects.create( |
264 | | - event_id=event_id, |
265 | | - project=group.project, |
266 | | - group=group, |
| 260 | + event = self.store_event( |
| 261 | + data={ |
| 262 | + 'event_id': event_id, |
| 263 | + 'timestamp': self.min_ago.isoformat()[:19], |
| 264 | + }, |
| 265 | + project_id=self.project.id |
267 | 266 | ) |
268 | 267 |
|
269 | 268 | self.login_as(user=self.user) |
270 | 269 | response = self.get_valid_response(query=' {} '.format('c' * 32)) |
271 | 270 | assert response['X-Sentry-Direct-Hit'] == '1' |
272 | 271 | assert len(response.data) == 1 |
273 | | - assert response.data[0]['id'] == six.text_type(group.id) |
| 272 | + assert response.data[0]['id'] == six.text_type(event.group.id) |
274 | 273 | assert response.data[0]['matchingEventId'] == event_id |
275 | 274 |
|
276 | 275 | def test_lookup_by_unknown_event_id(self): |
|
0 commit comments