4
4
from django .utils import timezone
5
5
from django .core .urlresolvers import reverse
6
6
from sentry .testutils import APITestCase , SnubaTestCase
7
+ from sentry .models import Group
7
8
8
9
9
10
class OrganizationEventDetailsTestBase (APITestCase , SnubaTestCase ):
@@ -19,27 +20,29 @@ def setUp(self):
19
20
self .store_event (
20
21
data = {
21
22
'event_id' : 'a' * 32 ,
22
- 'environment' : 'staging' ,
23
23
'timestamp' : three_min_ago ,
24
+ 'fingerprint' : ['group-1' ],
25
+
24
26
},
25
27
project_id = self .project .id ,
26
28
)
27
29
self .store_event (
28
30
data = {
29
31
'event_id' : 'b' * 32 ,
30
- 'environment' : 'staging' ,
31
32
'timestamp' : two_min_ago ,
33
+ 'fingerprint' : ['group-1' ],
32
34
},
33
35
project_id = self .project .id ,
34
36
)
35
37
self .store_event (
36
38
data = {
37
39
'event_id' : 'c' * 32 ,
38
- 'environment' : 'staging' ,
39
40
'timestamp' : min_ago ,
41
+ 'fingerprint' : ['group-2' ],
40
42
},
41
43
project_id = self .project .id ,
42
44
)
45
+ self .groups = Group .objects .all ()
43
46
44
47
45
48
class OrganizationEventDetailsEndpointTest (OrganizationEventDetailsTestBase ):
@@ -137,6 +140,24 @@ def test_no_event(self):
137
140
138
141
assert response .status_code == 404 , response .content
139
142
143
+ def test_query_with_issue_id (self ):
144
+ url = reverse (
145
+ 'sentry-api-0-organization-event-details-latest' ,
146
+ kwargs = {
147
+ 'organization_slug' : self .project .organization .slug ,
148
+ }
149
+ )
150
+ query = {'query' : 'issue.id:{}' .format (self .groups [1 ].id )}
151
+
152
+ with self .feature ('organizations:events-v2' ):
153
+ response = self .client .get (url , query , format = 'json' )
154
+
155
+ assert response .status_code == 200 , response .content
156
+ assert response .data ['id' ] == 'c' * 32
157
+ assert response .data ['previousEventID' ] is None
158
+ assert response .data ['nextEventID' ] is None
159
+ assert response .data ['projectSlug' ] == self .project .slug
160
+
140
161
141
162
class OrganizationEventDetailsOldestEndpointTest (OrganizationEventDetailsTestBase ):
142
163
def test_simple (self ):
@@ -182,3 +203,21 @@ def test_no_event(self):
182
203
response = self .client .get (url , format = 'json' )
183
204
184
205
assert response .status_code == 404 , response .content
206
+
207
+ def test_query_with_issue_id (self ):
208
+ url = reverse (
209
+ 'sentry-api-0-organization-event-details-oldest' ,
210
+ kwargs = {
211
+ 'organization_slug' : self .project .organization .slug ,
212
+ }
213
+ )
214
+ query = {'query' : 'issue.id:{}' .format (self .groups [1 ].id )}
215
+
216
+ with self .feature ('organizations:events-v2' ):
217
+ response = self .client .get (url , query , format = 'json' )
218
+
219
+ assert response .status_code == 200 , response .content
220
+ assert response .data ['id' ] == 'c' * 32
221
+ assert response .data ['previousEventID' ] is None
222
+ assert response .data ['nextEventID' ] is None
223
+ assert response .data ['projectSlug' ] == self .project .slug
0 commit comments