From 1423c7f1ed2933de1d2008c7cadead03d846bfaa Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Wed, 26 Mar 2025 17:15:42 -0400 Subject: [PATCH] fix(uptime): Improve organization_uptime_stats tests Fixes GH-86606 --- .../test_organization_uptime_stats.py | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/sentry/uptime/endpoints/test_organization_uptime_stats.py b/tests/sentry/uptime/endpoints/test_organization_uptime_stats.py index 168ff4be288816..4c0549bd540394 100644 --- a/tests/sentry/uptime/endpoints/test_organization_uptime_stats.py +++ b/tests/sentry/uptime/endpoints/test_organization_uptime_stats.py @@ -1,6 +1,5 @@ import uuid from datetime import datetime, timedelta, timezone -from unittest import skip from sentry.testutils.cases import UptimeCheckSnubaTestCase from sentry.testutils.helpers.datetime import freeze_time @@ -166,7 +165,9 @@ def test_simple_with_date_cutoff_rounded_resolution_past_cutoff(self): } def test_invalid_uptime_subscription_id(self): - """Test that the endpoint returns data for a simple uptime check.""" + """ + Test that an invalid uptime_subscription_id produces a 400 response. + """ response = self.get_response( self.organization.slug, project=[self.project.id], @@ -176,9 +177,13 @@ def test_invalid_uptime_subscription_id(self): resolution="1d", ) assert response.status_code == 400 + assert response.json() == "Invalid project uptime subscription ids provided" def test_no_uptime_subscription_id(self): - """Test that the endpoint returns data for a simple uptime check.""" + """ + Test that not sending any uptime_subscription_id produces a 400 + response. + """ response = self.get_response( self.organization.slug, project=[self.project.id], @@ -188,23 +193,28 @@ def test_no_uptime_subscription_id(self): resolution="1d", ) assert response.status_code == 400 + assert response.json() == "No project uptime subscription ids provided" - @skip("vgrozdanic: This test is flaky and should be skipped") def test_too_many_periods(self): - """Test that the endpoint returns data for a simple uptime check.""" - + """ + Test that requesting a high resolution across a large period of time + produces a 400 response. + """ response = self.get_response( self.organization.slug, project=[self.project.id], projectUptimeSubscriptionId=[str(self.project_uptime_subscription.id)], since=(datetime.now(timezone.utc) - timedelta(days=90)).timestamp(), until=datetime.now(timezone.utc).timestamp(), - resolution="1h", + resolution="1m", ) assert response.status_code == 400 + assert response.json() == "error making request" def test_too_many_uptime_subscription_ids(self): - """Test that the endpoint returns data for a simple uptime check.""" + """ + Test that sending a large nubmer of subscription IDs produces a 400 + """ response = self.get_response( self.organization.slug, @@ -215,6 +225,9 @@ def test_too_many_uptime_subscription_ids(self): resolution="1h", ) assert response.status_code == 400 + assert ( + response.json() == "Too many project uptime subscription ids provided. Maximum is 100" + ) # TODO(jferg): remove after 90 days