Skip to content

Commit

Permalink
feat(uptime): Call quotas.disable_seat when deleting monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jan 29, 2025
1 parent 369f09e commit 2437d8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/sentry/uptime/subscriptions/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def delete_uptime_subscriptions_for_project(

def delete_project_uptime_subscription(subscription: ProjectUptimeSubscription):
uptime_subscription = subscription.uptime_subscription
quotas.backend.disable_seat(DataCategory.UPTIME, subscription)
subscription.delete()
remove_uptime_subscription_if_unused(uptime_subscription)

Expand Down
8 changes: 6 additions & 2 deletions tests/sentry/uptime/subscriptions/test_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ def test_delete_other_modes(self):


class DeleteProjectUptimeSubscriptionTest(UptimeTestCase):
def test_other_subscriptions(self):
@mock.patch("sentry.quotas.backend.disable_seat")
def test_other_subscriptions(self, mock_disable_seat):
other_project = self.create_project()
proj_sub = get_or_create_project_uptime_subscription(
self.project,
Expand Down Expand Up @@ -673,8 +674,10 @@ def test_other_subscriptions(self):
proj_sub.refresh_from_db()

assert UptimeSubscription.objects.filter(id=other_sub.uptime_subscription_id).exists()
mock_disable_seat.assert_called_with(DataCategory.UPTIME, proj_sub)

def test_single_subscriptions(self):
@mock.patch("sentry.quotas.backend.disable_seat")
def test_single_subscriptions(self, mock_disable_seat):
proj_sub = get_or_create_project_uptime_subscription(
self.project,
self.environment,
Expand All @@ -691,6 +694,7 @@ def test_single_subscriptions(self):

with pytest.raises(UptimeSubscription.DoesNotExist):
proj_sub.uptime_subscription.refresh_from_db()
mock_disable_seat.assert_called_with(DataCategory.UPTIME, proj_sub)


class RemoveUptimeSubscriptionIfUnusedTest(UptimeTestCase):
Expand Down

0 comments on commit 2437d8c

Please sign in to comment.