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

fix(uptime): Improve organization_uptime_stats tests #88032

Merged
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
29 changes: 21 additions & 8 deletions tests/sentry/uptime/endpoints/test_organization_uptime_stats.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the main fix, I just set the resolution way lower so we will absolutely hit the period limit

)
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,
Expand All @@ -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
Expand Down
Loading