14
14
from sqlalchemy .ext .asyncio import AsyncSession
15
15
16
16
from fastapi_jsonapi .views .view_base import ViewBase
17
+ from tests .common import is_postgres_tests
17
18
from tests .fixtures .app import build_app_custom
18
19
from tests .fixtures .entities import build_workplace , create_user
19
20
from tests .misc .utils import fake
@@ -1044,7 +1045,7 @@ async def test_create_with_relationship_to_the_same_table(self):
1044
1045
"meta" : None ,
1045
1046
}
1046
1047
1047
- async def test_create_with_timestamp (self , async_session : AsyncSession ):
1048
+ async def test_create_with_timestamp_and_fetch (self , async_session : AsyncSession ):
1048
1049
resource_type = "contains_timestamp_model"
1049
1050
1050
1051
class ContainsTimestampAttrsSchema (BaseModel ):
@@ -1078,7 +1079,7 @@ class ContainsTimestampAttrsSchema(BaseModel):
1078
1079
"meta" : None ,
1079
1080
"jsonapi" : {"version" : "1.0" },
1080
1081
"data" : {
1081
- "type" : "contains_timestamp_model" ,
1082
+ "type" : resource_type ,
1082
1083
"attributes" : {"timestamp" : create_timestamp .isoformat ()},
1083
1084
"id" : entity_id ,
1084
1085
},
@@ -1087,7 +1088,14 @@ class ContainsTimestampAttrsSchema(BaseModel):
1087
1088
stms = select (ContainsTimestamp ).where (ContainsTimestamp .id == int (entity_id ))
1088
1089
entity_model : Optional [ContainsTimestamp ] = (await async_session .execute (stms )).scalar_one_or_none ()
1089
1090
assert entity_model
1090
- assert entity_model .timestamp .isoformat () == create_timestamp .replace (tzinfo = None ).isoformat ()
1091
+ assert (
1092
+ entity_model .timestamp .replace (tzinfo = None ).isoformat ()
1093
+ == create_timestamp .replace (tzinfo = None ).isoformat ()
1094
+ )
1095
+
1096
+ expected_response_timestamp = create_timestamp .replace (tzinfo = None ).isoformat ()
1097
+ if is_postgres_tests ():
1098
+ expected_response_timestamp = create_timestamp .replace ().isoformat ()
1091
1099
1092
1100
params = {
1093
1101
"filter" : json .dumps (
@@ -1109,8 +1117,8 @@ class ContainsTimestampAttrsSchema(BaseModel):
1109
1117
"jsonapi" : {"version" : "1.0" },
1110
1118
"data" : [
1111
1119
{
1112
- "type" : "contains_timestamp_model" ,
1113
- "attributes" : {"timestamp" : create_timestamp . replace ( tzinfo = None ). isoformat () },
1120
+ "type" : resource_type ,
1121
+ "attributes" : {"timestamp" : expected_response_timestamp },
1114
1122
"id" : entity_id ,
1115
1123
},
1116
1124
],
0 commit comments