Skip to content

Commit 14b61f8

Browse files
committed
fix
1 parent 39a3032 commit 14b61f8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

tests/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ def sqla_uri():
88
db_dir = Path(__file__).resolve().parent
99
testing_db_url = f"sqlite+aiosqlite:///{db_dir}/db.sqlite3"
1010
return testing_db_url
11+
12+
13+
def is_postgres_tests() -> bool:
14+
return "postgres" in sqla_uri()

tests/test_api/test_api_sqla_with_includes.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from sqlalchemy.ext.asyncio import AsyncSession
1616

1717
from fastapi_jsonapi.views.view_base import ViewBase
18+
from tests.common import is_postgres_tests
1819
from tests.fixtures.app import build_app_custom
1920
from tests.fixtures.entities import build_workplace, create_user
2021
from tests.misc.utils import fake
@@ -1219,7 +1220,7 @@ async def test_create_with_relationship_to_the_same_table(self):
12191220
"meta": None,
12201221
}
12211222

1222-
async def test_create_with_timestamp(self, async_session: AsyncSession):
1223+
async def test_create_with_timestamp_and_fetch(self, async_session: AsyncSession):
12231224
resource_type = "contains_timestamp_model"
12241225

12251226
class ContainsTimestampAttrsSchema(BaseModel):
@@ -1253,7 +1254,7 @@ class ContainsTimestampAttrsSchema(BaseModel):
12531254
"meta": None,
12541255
"jsonapi": {"version": "1.0"},
12551256
"data": {
1256-
"type": "contains_timestamp_model",
1257+
"type": resource_type,
12571258
"attributes": {"timestamp": create_timestamp.isoformat()},
12581259
"id": entity_id,
12591260
},
@@ -1262,7 +1263,14 @@ class ContainsTimestampAttrsSchema(BaseModel):
12621263
stms = select(ContainsTimestamp).where(ContainsTimestamp.id == int(entity_id))
12631264
entity_model: Optional[ContainsTimestamp] = (await async_session.execute(stms)).scalar_one_or_none()
12641265
assert entity_model
1265-
assert entity_model.timestamp.isoformat() == create_timestamp.replace(tzinfo=None).isoformat()
1266+
assert (
1267+
entity_model.timestamp.replace(tzinfo=None).isoformat()
1268+
== create_timestamp.replace(tzinfo=None).isoformat()
1269+
)
1270+
1271+
expected_response_timestamp = create_timestamp.replace(tzinfo=None).isoformat()
1272+
if is_postgres_tests():
1273+
expected_response_timestamp = create_timestamp.replace().isoformat()
12661274

12671275
params = {
12681276
"filter": json.dumps(
@@ -1284,8 +1292,8 @@ class ContainsTimestampAttrsSchema(BaseModel):
12841292
"jsonapi": {"version": "1.0"},
12851293
"data": [
12861294
{
1287-
"type": "contains_timestamp_model",
1288-
"attributes": {"timestamp": create_timestamp.replace(tzinfo=None).isoformat()},
1295+
"type": resource_type,
1296+
"attributes": {"timestamp": expected_response_timestamp},
12891297
"id": entity_id,
12901298
},
12911299
],

0 commit comments

Comments
 (0)