|
2 | 2 | from sentry.models.projectteam import ProjectTeam
|
3 | 3 | from sentry.models.rule import Rule
|
4 | 4 | from sentry.models.team import Team
|
| 5 | +from sentry.monitors.models import Monitor, MonitorType |
5 | 6 | from sentry.tasks.deletion.scheduled import run_scheduled_deletions
|
6 | 7 | from sentry.testutils.cases import TestCase
|
7 | 8 | from sentry.testutils.hybrid_cloud import HybridCloudTestMixin
|
@@ -44,3 +45,22 @@ def test_alert_blanking(self):
|
44 | 45 | rule.refresh_from_db()
|
45 | 46 | assert rule.owner_id is None, "Should be blank when team is deleted."
|
46 | 47 | assert alert_rule.owner_id is None, "Should be blank when team is deleted."
|
| 48 | + |
| 49 | + def test_monitor_blanking(self): |
| 50 | + team = self.create_team(name="test") |
| 51 | + monitor = Monitor.objects.create( |
| 52 | + organization_id=self.organization.id, |
| 53 | + project_id=self.project.id, |
| 54 | + type=MonitorType.CRON_JOB, |
| 55 | + name="My Awesome Monitor", |
| 56 | + owner_team_id=team.actor.id, |
| 57 | + ) |
| 58 | + self.ScheduledDeletion.schedule(team, days=0) |
| 59 | + |
| 60 | + with self.tasks(): |
| 61 | + run_scheduled_deletions() |
| 62 | + |
| 63 | + assert not Team.objects.filter(id=team.id).exists() |
| 64 | + |
| 65 | + monitor.refresh_from_db() |
| 66 | + assert monitor.owner_team_id is None, "Should be blank when team is deleted." |
0 commit comments