2
2
3
3
from django .utils import timezone
4
4
5
+ from sentry .analytics .events .issue_assigned import IssueAssignedEvent
6
+ from sentry .analytics .events .issue_resolved import IssueResolvedEvent
5
7
from sentry .models .groupassignee import GroupAssignee
6
8
from sentry .signals import (
7
9
issue_assigned ,
12
14
issue_update_priority ,
13
15
)
14
16
from sentry .testutils .cases import SnubaTestCase , TestCase
17
+ from sentry .testutils .helpers .analytics import assert_last_analytics_event
15
18
16
19
17
20
class SignalsTest (TestCase , SnubaTestCase ):
@@ -88,16 +91,18 @@ def test_issue_resolved_with_default_owner(self, mock_record):
88
91
resolution_type = "now" ,
89
92
sender = type (self .project ),
90
93
)
91
- mock_record .assert_called_once_with (
92
- "issue.resolved" ,
93
- user_id = None ,
94
- project_id = self .project .id ,
95
- default_user_id = self .organization .default_owner_id ,
96
- organization_id = self .organization .id ,
97
- group_id = self .group .id ,
98
- resolution_type = "now" ,
99
- issue_type = "error" ,
100
- issue_category = "error" ,
94
+ assert_last_analytics_event (
95
+ mock_record ,
96
+ IssueResolvedEvent (
97
+ user_id = None ,
98
+ project_id = self .project .id ,
99
+ default_user_id = self .organization .default_owner_id ,
100
+ organization_id = self .organization .id ,
101
+ group_id = self .group .id ,
102
+ resolution_type = "now" ,
103
+ issue_type = "error" ,
104
+ issue_category = "error" ,
105
+ ),
101
106
)
102
107
103
108
@patch ("sentry.analytics.record" )
@@ -115,16 +120,18 @@ def test_issue_resolved_without_default_owner(self, mock_record):
115
120
resolution_type = "now" ,
116
121
sender = type (project ),
117
122
)
118
- mock_record .assert_called_once_with (
119
- "issue.resolved" ,
120
- user_id = None ,
121
- project_id = project .id ,
122
- default_user_id = "unknown" ,
123
- organization_id = organization .id ,
124
- group_id = group .id ,
125
- resolution_type = "now" ,
126
- issue_type = "error" ,
127
- issue_category = "error" ,
123
+ assert_last_analytics_event (
124
+ mock_record ,
125
+ IssueResolvedEvent (
126
+ user_id = None ,
127
+ project_id = project .id ,
128
+ default_user_id = "unknown" ,
129
+ organization_id = organization .id ,
130
+ group_id = group .id ,
131
+ resolution_type = "now" ,
132
+ issue_type = "error" ,
133
+ issue_category = "error" ,
134
+ ),
128
135
)
129
136
130
137
@patch ("sentry.analytics.record" )
@@ -182,12 +189,14 @@ def test_issue_assigned_with_default_owner(self, mock_record):
182
189
transition_type = "manual" ,
183
190
sender = type (self .project ),
184
191
)
185
- mock_record .assert_called_once_with (
186
- "issue.assigned" ,
187
- user_id = None ,
188
- default_user_id = self .organization .default_owner_id ,
189
- organization_id = self .organization .id ,
190
- group_id = self .group .id ,
192
+ assert_last_analytics_event (
193
+ mock_record ,
194
+ IssueAssignedEvent (
195
+ user_id = None ,
196
+ default_user_id = self .organization .default_owner_id ,
197
+ organization_id = self .organization .id ,
198
+ group_id = self .group .id ,
199
+ ),
191
200
)
192
201
193
202
@patch ("sentry.analytics.record" )
@@ -207,10 +216,12 @@ def test_issue_assigned_without_default_owner(self, mock_record):
207
216
transition_type = "manual" ,
208
217
sender = type (project ),
209
218
)
210
- mock_record .assert_called_once_with (
211
- "issue.assigned" ,
212
- user_id = None ,
213
- default_user_id = "unknown" ,
214
- organization_id = organization .id ,
215
- group_id = group .id ,
219
+ assert_last_analytics_event (
220
+ mock_record ,
221
+ IssueAssignedEvent (
222
+ user_id = None ,
223
+ default_user_id = "unknown" ,
224
+ organization_id = organization .id ,
225
+ group_id = group .id ,
226
+ ),
216
227
)
0 commit comments