1515from sqlalchemy .ext .asyncio import AsyncSession
1616
1717from fastapi_jsonapi .views .view_base import ViewBase
18+ from tests .common import is_postgres_tests
1819from tests .fixtures .app import build_app_custom
1920from tests .fixtures .entities import build_workplace , create_user
2021from 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