|
15 | 15 | from sentry.models.project import Project
|
16 | 16 | from sentry.models.rule import Rule
|
17 | 17 | from sentry.organizations.services.organization import organization_service
|
| 18 | +from sentry.receivers.rules import DEFAULT_RULE_LABEL |
18 | 19 | from sentry.signals import (
|
19 | 20 | alert_rule_created,
|
20 | 21 | event_processed,
|
|
30 | 31 | from sentry.silo.base import SiloMode
|
31 | 32 | from sentry.testutils.cases import TestCase
|
32 | 33 | from sentry.testutils.helpers.datetime import before_now
|
| 34 | +from sentry.testutils.helpers.features import with_feature |
33 | 35 | from sentry.testutils.outbox import outbox_runner
|
34 | 36 | from sentry.testutils.silo import assume_test_silo_mode
|
35 | 37 | from sentry.testutils.skips import requires_snuba
|
36 | 38 | from sentry.utils.samples import load_data
|
| 39 | +from sentry.workflow_engine.models import Workflow |
37 | 40 |
|
38 | 41 | pytestmark = [requires_snuba]
|
39 | 42 |
|
@@ -138,6 +141,23 @@ def test_project_created(self):
|
138 | 141 | )
|
139 | 142 | assert task is not None
|
140 | 143 |
|
| 144 | + def test_project_created__default_rule(self): |
| 145 | + project = self.create_project() |
| 146 | + project_created.send(project=project, user=self.user, sender=type(project)) |
| 147 | + |
| 148 | + assert Rule.objects.filter(project=project).exists() |
| 149 | + assert not Workflow.objects.filter(organization=project.organization).exists() |
| 150 | + |
| 151 | + @with_feature("organizations:workflow-engine-issue-alert-dual-write") |
| 152 | + def test_project_created__default_workflow(self): |
| 153 | + project = self.create_project() |
| 154 | + project_created.send(project=project, user=self.user, sender=type(project)) |
| 155 | + |
| 156 | + assert Rule.objects.filter(project=project).exists() |
| 157 | + assert Workflow.objects.filter( |
| 158 | + organization=project.organization, name=DEFAULT_RULE_LABEL |
| 159 | + ).exists() |
| 160 | + |
141 | 161 | @patch("sentry.analytics.record")
|
142 | 162 | def test_project_created_with_origin(self, record_analytics):
|
143 | 163 | project = self.create_project()
|
|
0 commit comments