1010from mock import patch , Mock
1111
1212from sentry .models import (
13- Activity , ApiToken , EventMapping , Group , GroupAssignee , GroupBookmark , GroupHash ,
13+ Activity , ApiToken , Group , GroupAssignee , GroupBookmark , GroupHash ,
1414 GroupLink , GroupResolution , GroupSeen , GroupShare , GroupSnooze , GroupStatus , GroupSubscription ,
1515 GroupTombstone , ExternalIssue , Integration , Release , OrganizationIntegration , UserOption
1616)
17- from sentry .models .event import Event
1817from sentry .testutils import APITestCase , SnubaTestCase
1918from sentry .testutils .helpers import parse_link_header
2019from six .moves .urllib .parse import quote
@@ -192,31 +191,31 @@ def test_auto_resolved(self):
192191 def test_lookup_by_event_id (self ):
193192 project = self .project
194193 project .update_option ('sentry:resolve_age' , 1 )
195- group = self .create_group (checksum = 'a' * 32 )
196- self .create_group (checksum = 'b' * 32 )
197194 event_id = 'c' * 32
198- event = Event .objects .create (project_id = self .project .id , event_id = event_id )
199- EventMapping .objects .create (
200- event_id = event_id ,
201- project = group .project ,
202- group = group ,
195+ event = self .store_event (
196+ data = {
197+ 'event_id' : event_id ,
198+ 'timestamp' : self .min_ago .isoformat ()[:19 ],
199+ },
200+ project_id = self .project .id
203201 )
204-
205202 self .login_as (user = self .user )
206203
207204 response = self .client .get (u'{}?query={}' .format (self .path , 'c' * 32 ), format = 'json' )
208205 assert response .status_code == 200
209206 assert len (response .data ) == 1
210- assert response .data [0 ]['id' ] == six .text_type (group .id )
207+ assert response .data [0 ]['id' ] == six .text_type (event . group .id )
211208 assert response .data [0 ]['matchingEventId' ] == event .id
212209
213210 def test_lookup_by_event_with_matching_environment (self ):
214211 project = self .project
215212 project .update_option ('sentry:resolve_age' , 1 )
216213 self .create_environment (name = "test" , project = project )
214+
217215 event = self .store_event (
218216 data = {
219217 'environment' : 'test' ,
218+ 'timestamp' : self .min_ago .isoformat ()[:19 ],
220219 },
221220 project_id = self .project .id ,
222221 )
@@ -235,21 +234,20 @@ def test_lookup_by_event_with_matching_environment(self):
235234 def test_lookup_by_event_id_with_whitespace (self ):
236235 project = self .project
237236 project .update_option ('sentry:resolve_age' , 1 )
238- group = self .create_group ( checksum = 'a' * 32 )
239- self . create_group ( checksum = 'b' * 32 )
240- EventMapping . objects . create (
241- event_id = 'c' * 32 ,
242- project = group . project ,
243- group = group ,
237+ event = self .store_event (
238+ data = {
239+ 'event_id' : 'c' * 32 ,
240+ 'timestamp' : self . min_ago . isoformat ()[: 19 ] ,
241+ } ,
242+ project_id = self . project . id
244243 )
245-
246244 self .login_as (user = self .user )
247245 response = self .client .get (
248246 u'{}?query=%20%20{}%20%20' .format (self .path , 'c' * 32 ), format = 'json'
249247 )
250248 assert response .status_code == 200
251249 assert len (response .data ) == 1
252- assert response .data [0 ]['id' ] == six .text_type (group .id )
250+ assert response .data [0 ]['id' ] == six .text_type (event . group .id )
253251
254252 def test_lookup_by_unknown_event_id (self ):
255253 project = self .project
0 commit comments