Skip to content

Commit 55f6da6

Browse files
committed
fix
1 parent 9060698 commit 55f6da6

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
@@ -14,6 +14,7 @@
1414
from sqlalchemy.ext.asyncio import AsyncSession
1515

1616
from fastapi_jsonapi.views.view_base import ViewBase
17+
from tests.common import is_postgres_tests
1718
from tests.fixtures.app import build_app_custom
1819
from tests.fixtures.entities import build_workplace, create_user
1920
from tests.misc.utils import fake
@@ -1044,7 +1045,7 @@ async def test_create_with_relationship_to_the_same_table(self):
10441045
"meta": None,
10451046
}
10461047

1047-
async def test_create_with_timestamp(self, async_session: AsyncSession):
1048+
async def test_create_with_timestamp_and_fetch(self, async_session: AsyncSession):
10481049
resource_type = "contains_timestamp_model"
10491050

10501051
class ContainsTimestampAttrsSchema(BaseModel):
@@ -1078,7 +1079,7 @@ class ContainsTimestampAttrsSchema(BaseModel):
10781079
"meta": None,
10791080
"jsonapi": {"version": "1.0"},
10801081
"data": {
1081-
"type": "contains_timestamp_model",
1082+
"type": resource_type,
10821083
"attributes": {"timestamp": create_timestamp.isoformat()},
10831084
"id": entity_id,
10841085
},
@@ -1087,7 +1088,14 @@ class ContainsTimestampAttrsSchema(BaseModel):
10871088
stms = select(ContainsTimestamp).where(ContainsTimestamp.id == int(entity_id))
10881089
entity_model: Optional[ContainsTimestamp] = (await async_session.execute(stms)).scalar_one_or_none()
10891090
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()
10911099

10921100
params = {
10931101
"filter": json.dumps(
@@ -1109,8 +1117,8 @@ class ContainsTimestampAttrsSchema(BaseModel):
11091117
"jsonapi": {"version": "1.0"},
11101118
"data": [
11111119
{
1112-
"type": "contains_timestamp_model",
1113-
"attributes": {"timestamp": create_timestamp.replace(tzinfo=None).isoformat()},
1120+
"type": resource_type,
1121+
"attributes": {"timestamp": expected_response_timestamp},
11141122
"id": entity_id,
11151123
},
11161124
],

0 commit comments

Comments
 (0)