Skip to content

Commit ca23764

Browse files
ref: remove calls to iso_format in testutils (#82461)
<!-- Describe your PR here. -->
1 parent 6a22b21 commit ca23764

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/sentry/integrations/github/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _get_token(self, prepared_request: PreparedRequest) -> str | None:
141141
access_token: str | None = self.integration.metadata.get("access_token")
142142
expires_at: str | None = self.integration.metadata.get("expires_at")
143143
is_expired = (
144-
bool(expires_at) and datetime.strptime(cast(str, expires_at), "%Y-%m-%dT%H:%M:%S") < now
144+
bool(expires_at) and datetime.fromisoformat(expires_at).replace(tzinfo=None) < now
145145
)
146146
should_refresh = not access_token or not expires_at or is_expired
147147

src/sentry/testutils/cases.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
from sentry.snuba.metrics.naming_layer.public import TransactionMetricKey
133133
from sentry.tagstore.snuba.backend import SnubaTagStorage
134134
from sentry.testutils.factories import get_fixture_path
135-
from sentry.testutils.helpers.datetime import before_now, iso_format
135+
from sentry.testutils.helpers.datetime import before_now
136136
from sentry.testutils.helpers.notifications import TEST_ISSUE_OCCURRENCE
137137
from sentry.testutils.helpers.slack import install_slack
138138
from sentry.testutils.pytest.selenium import Browser
@@ -2126,7 +2126,7 @@ def create_event(self, timestamp, fingerprint=None, user=None):
21262126
data = {
21272127
"event_id": event_id,
21282128
"fingerprint": [fingerprint],
2129-
"timestamp": iso_format(timestamp),
2129+
"timestamp": timestamp.isoformat(),
21302130
"type": "error",
21312131
# This is necessary because event type error should not exist without
21322132
# an exception being in the payload
@@ -3388,7 +3388,7 @@ def load_default(self) -> Event:
33883388
start, _ = self.get_start_end_from_day_ago(1000)
33893389
return self.store_event(
33903390
{
3391-
"timestamp": iso_format(start),
3391+
"timestamp": start.isoformat(),
33923392
"contexts": {
33933393
"trace": {
33943394
"type": "trace",

src/sentry/testutils/fixtures.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from sentry.snuba.models import QuerySubscription
3030
from sentry.tempest.models import TempestCredentials
3131
from sentry.testutils.factories import Factories
32-
from sentry.testutils.helpers.datetime import before_now, iso_format
32+
from sentry.testutils.helpers.datetime import before_now
3333
from sentry.testutils.silo import assume_test_silo_mode
3434

3535
# XXX(dcramer): this is a compatibility layer to transition to pytest-based fixtures
@@ -104,7 +104,7 @@ def event(self):
104104
data={
105105
"event_id": "a" * 32,
106106
"message": "\u3053\u3093\u306b\u3061\u306f",
107-
"timestamp": iso_format(before_now(seconds=1)),
107+
"timestamp": before_now(seconds=1).isoformat(),
108108
},
109109
project_id=self.project.id,
110110
)
@@ -129,7 +129,7 @@ def integration(self):
129129
external_id="github:1",
130130
metadata={
131131
"access_token": "xxxxx-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
132-
"expires_at": iso_format(timezone.now() + timedelta(days=14)),
132+
"expires_at": (timezone.now() + timedelta(days=14)).isoformat(),
133133
},
134134
)
135135
integration.add_organization(self.organization, self.user)

0 commit comments

Comments
 (0)