|
5 | 5 | from sentry.integrations.jira.integration import JiraIntegration
|
6 | 6 | from sentry.integrations.pagerduty.client import PagerDutyClient
|
7 | 7 | from sentry.integrations.pagerduty.utils import PagerDutyServiceDict, add_service
|
8 |
| -from sentry.notifications.notification_action.group_type_notification_registry import ( |
9 |
| - IssueAlertRegistryHandler, |
10 |
| -) |
11 |
| -from sentry.notifications.notification_action.issue_alert_registry import ( |
12 |
| - PagerDutyIssueAlertHandler, |
13 |
| - PluginIssueAlertHandler, |
14 |
| -) |
15 | 8 | from sentry.rules.actions.notify_event import NotifyEventAction
|
16 | 9 | from sentry.shared_integrations.exceptions import IntegrationFormError
|
17 | 10 | from sentry.silo.base import SiloMode
|
18 | 11 | from sentry.testutils.cases import APITestCase
|
19 |
| -from sentry.testutils.helpers import apply_feature_flag_on_cls |
20 | 12 | from sentry.testutils.silo import assume_test_silo_mode
|
21 | 13 | from sentry.testutils.skips import requires_snuba
|
22 |
| -from tests.sentry.workflow_engine.test_base import BaseWorkflowTest |
23 | 14 |
|
24 | 15 | pytestmark = [requires_snuba]
|
25 | 16 |
|
@@ -147,169 +138,3 @@ def test_sample_event_raises_exceptions(self, mock_sdk_capture, mock_create_issu
|
147 | 138 | def test_no_events(self):
|
148 | 139 | response = self.get_response(self.organization.slug, self.project.slug)
|
149 | 140 | assert response.status_code == 400
|
150 |
| - |
151 |
| - |
152 |
| -@apply_feature_flag_on_cls("organizations:workflow-engine-test-notifications") |
153 |
| -class ProjectRuleActionsEndpointWorkflowEngineTest(APITestCase, BaseWorkflowTest): |
154 |
| - endpoint = "sentry-api-0-project-rule-actions" |
155 |
| - method = "POST" |
156 |
| - |
157 |
| - def setUp(self): |
158 |
| - super().setUp() |
159 |
| - self.login_as(self.user) |
160 |
| - self.workflow = self.create_workflow() |
161 |
| - |
162 |
| - def setup_pd_service(self) -> PagerDutyServiceDict: |
163 |
| - service_info = { |
164 |
| - "type": "service", |
165 |
| - "integration_key": "PND123", |
166 |
| - "service_name": "Sentry Service", |
167 |
| - } |
168 |
| - _integration, org_integration = self.create_provider_integration_for( |
169 |
| - provider="pagerduty", |
170 |
| - name="Example PagerDuty", |
171 |
| - external_id="example-pd", |
172 |
| - metadata={"services": [service_info]}, |
173 |
| - organization=self.organization, |
174 |
| - user=self.user, |
175 |
| - ) |
176 |
| - with assume_test_silo_mode(SiloMode.CONTROL): |
177 |
| - return add_service( |
178 |
| - org_integration, |
179 |
| - service_name=service_info["service_name"], |
180 |
| - integration_key=service_info["integration_key"], |
181 |
| - ) |
182 |
| - |
183 |
| - @mock.patch.object(NotifyEventAction, "after") |
184 |
| - @mock.patch( |
185 |
| - "sentry.notifications.notification_action.registry.issue_alert_handler_registry.get", |
186 |
| - return_value=PluginIssueAlertHandler, |
187 |
| - ) |
188 |
| - def test_actions(self, mock_get_handler, action): |
189 |
| - action_data = [ |
190 |
| - { |
191 |
| - "id": "sentry.rules.actions.notify_event.NotifyEventAction", |
192 |
| - } |
193 |
| - ] |
194 |
| - |
195 |
| - self.get_success_response(self.organization.slug, self.project.slug, actions=action_data) |
196 |
| - assert action.called |
197 |
| - |
198 |
| - def test_unknown_action_returns_400(self): |
199 |
| - action_data = [ |
200 |
| - { |
201 |
| - "id": "sentry.rules.actions.fake_action.FakeAction", |
202 |
| - } |
203 |
| - ] |
204 |
| - |
205 |
| - response = self.get_error_response( |
206 |
| - self.organization.slug, self.project.slug, actions=action_data |
207 |
| - ) |
208 |
| - assert response.status_code == 400 |
209 |
| - |
210 |
| - @mock.patch.object(PagerDutyClient, "send_trigger") |
211 |
| - @mock.patch( |
212 |
| - "sentry.notifications.notification_action.registry.group_type_notification_registry.get", |
213 |
| - return_value=IssueAlertRegistryHandler, |
214 |
| - ) |
215 |
| - @mock.patch( |
216 |
| - "sentry.notifications.notification_action.registry.issue_alert_handler_registry.get", |
217 |
| - return_value=PagerDutyIssueAlertHandler, |
218 |
| - ) |
219 |
| - def test_name_action_default( |
220 |
| - self, mock_get_issue_alert_handler, mock_get_group_type_handler, mock_send_trigger |
221 |
| - ): |
222 |
| - """ |
223 |
| - Tests that label will be used as 'Test Alert' if not present. Uses PagerDuty since those |
224 |
| - notifications will differ based on the name of the alert. |
225 |
| - """ |
226 |
| - service_info = self.setup_pd_service() |
227 |
| - action_data = [ |
228 |
| - { |
229 |
| - "account": service_info["integration_id"], |
230 |
| - "service": service_info["id"], |
231 |
| - "severity": "info", |
232 |
| - "id": "sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction", |
233 |
| - } |
234 |
| - ] |
235 |
| - self.get_success_response(self.organization.slug, self.project.slug, actions=action_data) |
236 |
| - |
237 |
| - assert mock_send_trigger.call_count == 1 |
238 |
| - pagerduty_data = mock_send_trigger.call_args.kwargs.get("data") |
239 |
| - assert pagerduty_data["payload"]["summary"].startswith("[Test Alert]:") |
240 |
| - |
241 |
| - @mock.patch.object(PagerDutyClient, "send_trigger") |
242 |
| - @mock.patch( |
243 |
| - "sentry.notifications.notification_action.registry.group_type_notification_registry.get", |
244 |
| - return_value=IssueAlertRegistryHandler, |
245 |
| - ) |
246 |
| - @mock.patch( |
247 |
| - "sentry.notifications.notification_action.registry.issue_alert_handler_registry.get", |
248 |
| - return_value=PagerDutyIssueAlertHandler, |
249 |
| - ) |
250 |
| - def test_name_action_with_custom_name( |
251 |
| - self, mock_get_issue_alert_handler, mock_get_group_type_handler, mock_send_trigger |
252 |
| - ): |
253 |
| - """ |
254 |
| - Tests that custom names can be provided to the test notification. Uses PagerDuty since those |
255 |
| - notifications will differ based on the name of the alert. |
256 |
| - """ |
257 |
| - service_info = self.setup_pd_service() |
258 |
| - action_data = [ |
259 |
| - { |
260 |
| - "account": service_info["integration_id"], |
261 |
| - "service": service_info["id"], |
262 |
| - "severity": "info", |
263 |
| - "id": "sentry.integrations.pagerduty.notify_action.PagerDutyNotifyServiceAction", |
264 |
| - } |
265 |
| - ] |
266 |
| - custom_alert_name = "Check #feed-issues" |
267 |
| - |
268 |
| - self.get_success_response( |
269 |
| - self.organization.slug, self.project.slug, actions=action_data, name=custom_alert_name |
270 |
| - ) |
271 |
| - assert mock_send_trigger.call_count == 1 |
272 |
| - pagerduty_data = mock_send_trigger.call_args.kwargs.get("data") |
273 |
| - assert pagerduty_data["payload"]["summary"].startswith(f"[{custom_alert_name}]:") |
274 |
| - |
275 |
| - @mock.patch.object(JiraIntegration, "create_issue") |
276 |
| - @mock.patch.object(sentry_sdk, "capture_exception") |
277 |
| - def test_sample_event_raises_exceptions_workflow_engine( |
278 |
| - self, mock_sdk_capture, mock_create_issue |
279 |
| - ): |
280 |
| - with assume_test_silo_mode(SiloMode.CONTROL): |
281 |
| - self.jira_integration = self.create_provider_integration( |
282 |
| - provider="jira", name="Jira", external_id="jira:1" |
283 |
| - ) |
284 |
| - self.jira_integration.add_organization(self.organization, self.user) |
285 |
| - |
286 |
| - form_errors = {"broken": "something went wrong"} |
287 |
| - mock_create_issue.side_effect = IntegrationFormError(form_errors) |
288 |
| - mock_sdk_capture.return_value = "abc-1234" |
289 |
| - action_data = [ |
290 |
| - { |
291 |
| - "id": "sentry.integrations.jira.notify_action.JiraCreateTicketAction", |
292 |
| - "dynamic_form_fields": { |
293 |
| - "fake_field": "fake_value", |
294 |
| - }, |
295 |
| - } |
296 |
| - ] |
297 |
| - |
298 |
| - response = self.get_error_response( |
299 |
| - self.organization.slug, self.project.slug, actions=action_data |
300 |
| - ) |
301 |
| - assert response.status_code == 400 |
302 |
| - assert mock_create_issue.call_count == 1 |
303 |
| - assert response.data == {"actions": [str(form_errors)]} |
304 |
| - |
305 |
| - mock_create_issue.side_effect = Exception("Something went wrong") |
306 |
| - response = self.get_error_response( |
307 |
| - self.organization.slug, self.project.slug, actions=action_data |
308 |
| - ) |
309 |
| - actions = response.data.get("actions") |
310 |
| - assert actions is not None |
311 |
| - assert actions == ["An unexpected error occurred. Error ID: 'abc-1234'"] |
312 |
| - |
313 |
| - def test_no_events(self): |
314 |
| - response = self.get_response(self.organization.slug, self.project.slug) |
315 |
| - assert response.status_code == 400 |
0 commit comments