Skip to content

Commit

Permalink
ref: remove calls to iso_format in testutils (#82461)
Browse files Browse the repository at this point in the history
<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Dec 20, 2024
1 parent 6a22b21 commit ca23764
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sentry/integrations/github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _get_token(self, prepared_request: PreparedRequest) -> str | None:
access_token: str | None = self.integration.metadata.get("access_token")
expires_at: str | None = self.integration.metadata.get("expires_at")
is_expired = (
bool(expires_at) and datetime.strptime(cast(str, expires_at), "%Y-%m-%dT%H:%M:%S") < now
bool(expires_at) and datetime.fromisoformat(expires_at).replace(tzinfo=None) < now
)
should_refresh = not access_token or not expires_at or is_expired

Expand Down
6 changes: 3 additions & 3 deletions src/sentry/testutils/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
from sentry.snuba.metrics.naming_layer.public import TransactionMetricKey
from sentry.tagstore.snuba.backend import SnubaTagStorage
from sentry.testutils.factories import get_fixture_path
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.testutils.helpers.datetime import before_now
from sentry.testutils.helpers.notifications import TEST_ISSUE_OCCURRENCE
from sentry.testutils.helpers.slack import install_slack
from sentry.testutils.pytest.selenium import Browser
Expand Down Expand Up @@ -2126,7 +2126,7 @@ def create_event(self, timestamp, fingerprint=None, user=None):
data = {
"event_id": event_id,
"fingerprint": [fingerprint],
"timestamp": iso_format(timestamp),
"timestamp": timestamp.isoformat(),
"type": "error",
# This is necessary because event type error should not exist without
# an exception being in the payload
Expand Down Expand Up @@ -3388,7 +3388,7 @@ def load_default(self) -> Event:
start, _ = self.get_start_end_from_day_ago(1000)
return self.store_event(
{
"timestamp": iso_format(start),
"timestamp": start.isoformat(),
"contexts": {
"trace": {
"type": "trace",
Expand Down
6 changes: 3 additions & 3 deletions src/sentry/testutils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sentry.snuba.models import QuerySubscription
from sentry.tempest.models import TempestCredentials
from sentry.testutils.factories import Factories
from sentry.testutils.helpers.datetime import before_now, iso_format
from sentry.testutils.helpers.datetime import before_now
from sentry.testutils.silo import assume_test_silo_mode

# XXX(dcramer): this is a compatibility layer to transition to pytest-based fixtures
Expand Down Expand Up @@ -104,7 +104,7 @@ def event(self):
data={
"event_id": "a" * 32,
"message": "\u3053\u3093\u306b\u3061\u306f",
"timestamp": iso_format(before_now(seconds=1)),
"timestamp": before_now(seconds=1).isoformat(),
},
project_id=self.project.id,
)
Expand All @@ -129,7 +129,7 @@ def integration(self):
external_id="github:1",
metadata={
"access_token": "xxxxx-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
"expires_at": iso_format(timezone.now() + timedelta(days=14)),
"expires_at": (timezone.now() + timedelta(days=14)).isoformat(),
},
)
integration.add_organization(self.organization, self.user)
Expand Down

0 comments on commit ca23764

Please sign in to comment.