Skip to content

Commit c69c9e5

Browse files
committed
Fixing datetime type issue.
1 parent a2ec61e commit c69c9e5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

stac_fastapi/tests/api/test_api.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import uuid
2-
from datetime import timedelta
2+
from datetime import datetime, timedelta
33

44
import pytest
55

@@ -251,7 +251,9 @@ async def test_app_sort_extension_get_asc(app_client, txn_client, ctx):
251251

252252
second_item = dict(first_item)
253253
second_item["id"] = "another-item"
254-
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
254+
another_item_date = datetime.strptime(
255+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
256+
) - timedelta(days=1)
255257
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
256258
"+00:00", "Z"
257259
)
@@ -271,7 +273,9 @@ async def test_app_sort_extension_get_desc(app_client, txn_client, ctx):
271273

272274
second_item = dict(first_item)
273275
second_item["id"] = "another-item"
274-
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
276+
another_item_date = datetime.strptime(
277+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
278+
) - timedelta(days=1)
275279
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
276280
"+00:00", "Z"
277281
)
@@ -290,7 +294,9 @@ async def test_app_sort_extension_post_asc(app_client, txn_client, ctx):
290294

291295
second_item = dict(first_item)
292296
second_item["id"] = "another-item"
293-
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
297+
another_item_date = datetime.strptime(
298+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
299+
) - timedelta(days=1)
294300
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
295301
"+00:00", "Z"
296302
)
@@ -313,7 +319,9 @@ async def test_app_sort_extension_post_desc(app_client, txn_client, ctx):
313319

314320
second_item = dict(first_item)
315321
second_item["id"] = "another-item"
316-
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
322+
another_item_date = datetime.strptime(
323+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
324+
) - timedelta(days=1)
317325
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
318326
"+00:00", "Z"
319327
)

0 commit comments

Comments
 (0)