Skip to content

Commit 5c43acc

Browse files
committed
WIP test
1 parent 17814e3 commit 5c43acc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

packages/postgres-database/tests/test_utils_projects.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
# pylint: disable=too-many-arguments
55
import uuid
66
from collections.abc import Awaitable, Callable
7-
from datetime import datetime
7+
from datetime import datetime, timezone
88
from typing import Any, AsyncIterator
99

1010
import pytest
1111
import sqlalchemy
12+
import sqlalchemy as sa
1213
from aiopg.sa.connection import SAConnection
1314
from aiopg.sa.result import RowProxy
1415
from faker import Faker
16+
from pydantic import parse_obj_as
1517
from simcore_postgres_database.models.projects import projects
1618
from simcore_postgres_database.utils_projects import (
1719
DBProjectNotFoundError,
1820
ProjectsRepo,
1921
)
22+
from simcore_postgres_database.utils_repos import transaction_context
2023
from sqlalchemy.ext.asyncio import AsyncEngine
2124

2225

@@ -51,6 +54,26 @@ async def registered_project(
5154
await _delete_project(connection, project["uuid"])
5255

5356

57+
@pytest.mark.parametrize("expected", (datetime.now(tz=timezone.utc), None))
58+
async def test_get_project_trashed_at_column_can_be_converted_to_datetime(
59+
asyncpg_engine: AsyncEngine, registered_project: dict, expected: datetime | None
60+
):
61+
project_id = registered_project["uuid"]
62+
63+
async with transaction_context(asyncpg_engine) as conn:
64+
result = await conn.execute(
65+
projects.update()
66+
.values(trashed_at=expected)
67+
.where(projects.c.uuid == project_id)
68+
.returning(sa.literal_column("*"))
69+
)
70+
71+
row = result.fetchone()
72+
73+
trashed_at = parse_obj_as(datetime | None, row.trashed_at)
74+
assert trashed_at == expected
75+
76+
5477
async def test_get_project_last_change_date(
5578
asyncpg_engine: AsyncEngine, registered_project: dict, faker: Faker
5679
):

0 commit comments

Comments
 (0)