Browse Source

test(snuba): Avoid risk of future events in snuba tests (#43810)

Matt Gaunt-Seo @ Sentry.io 2 years ago
parent
commit
090a4eb53e

+ 2 - 2
tests/snuba/api/endpoints/test_group_events.py

@@ -441,14 +441,14 @@ class GroupEventsTest(APITestCase, SnubaTestCase, SearchIssueTestMixin, Performa
             self.user.id,
             [f"{GroupType.PROFILE_BLOCKED_THREAD.value}-group1"],
             "prod",
-            timezone.now().replace(hour=0, minute=0, second=0) + timedelta(minutes=1),
+            before_now(hours=1).replace(tzinfo=timezone.utc),
         )
         event_2, _, _ = self.store_search_issue(
             self.project.id,
             self.user.id,
             [f"{GroupType.PROFILE_BLOCKED_THREAD.value}-group1"],
             "prod",
-            timezone.now().replace(hour=0, minute=0, second=0) + timedelta(minutes=1),
+            before_now(hours=1).replace(tzinfo=timezone.utc),
         )
 
         self.login_as(user=self.user)

+ 2 - 2
tests/snuba/api/endpoints/test_organization_events.py

@@ -611,7 +611,7 @@ class OrganizationEventsEndpointTest(APITestCase, SnubaTestCase, SearchIssueTest
             self.user.id,
             [f"{GroupType.PROFILE_BLOCKED_THREAD.value}-group1"],
             "prod",
-            timezone.now().replace(hour=0, minute=0, second=0) + timedelta(minutes=1),
+            before_now(hours=1).replace(tzinfo=timezone.utc),
             user=user_data,
         )
 
@@ -3020,7 +3020,7 @@ class OrganizationEventsEndpointTest(APITestCase, SnubaTestCase, SearchIssueTest
             1,
             ["group1-fingerprint"],
             None,
-            timezone.now().replace(hour=0, minute=0, second=0) + timedelta(minutes=10),
+            before_now(hours=1).replace(tzinfo=timezone.utc),
             user=user_data,
         )
 

+ 1 - 2
tests/snuba/api/endpoints/test_organization_events_meta.py

@@ -1,4 +1,3 @@
-from datetime import timedelta
 from unittest import mock
 
 import pytest
@@ -120,7 +119,7 @@ class OrganizationEventsMetaEndpoint(APITestCase, SnubaTestCase, SearchIssueTest
             self.user.id,
             [f"{GroupType.PROFILE_BLOCKED_THREAD.value}-group1"],
             "prod",
-            timezone.now().replace(hour=0, minute=0, second=0) + timedelta(minutes=1),
+            before_now(hours=1).replace(tzinfo=timezone.utc),
         )
         url = reverse(
             "sentry-api-0-organization-events-meta",