Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(uptime): Call quotas.disable_seat when deleting monitors #84290

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading