Skip to content

Commit e35b52b

Browse files
committed
adds exists
1 parent 054551d commit e35b52b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

packages/postgres-database/tests/test_utils_projects.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,42 @@ async def test_get_project_trashed_column_can_be_converted_to_datetime(
7474
assert trashed == expected
7575

7676

77+
@pytest.mark.parametrize("with_explicit_connection", [True, False])
78+
async def test_projects_repo_exists_with_existing_project(
79+
asyncpg_engine: AsyncEngine,
80+
registered_project: dict,
81+
with_explicit_connection: bool,
82+
):
83+
projects_repo = ProjectsRepo(asyncpg_engine)
84+
project_uuid = registered_project["uuid"]
85+
86+
if with_explicit_connection:
87+
async with transaction_context(asyncpg_engine) as conn:
88+
exists = await projects_repo.exists(project_uuid, connection=conn)
89+
else:
90+
exists = await projects_repo.exists(project_uuid)
91+
92+
assert exists is True
93+
94+
95+
@pytest.mark.parametrize("with_explicit_connection", [True, False])
96+
async def test_projects_repo_exists_with_non_existing_project(
97+
asyncpg_engine: AsyncEngine,
98+
faker: Faker,
99+
with_explicit_connection: bool,
100+
):
101+
projects_repo = ProjectsRepo(asyncpg_engine)
102+
non_existing_uuid = faker.uuid4()
103+
104+
if with_explicit_connection:
105+
async with transaction_context(asyncpg_engine) as conn:
106+
exists = await projects_repo.exists(non_existing_uuid, connection=conn)
107+
else:
108+
exists = await projects_repo.exists(non_existing_uuid)
109+
110+
assert exists is False
111+
112+
77113
async def test_get_project_last_change_date(
78114
asyncpg_engine: AsyncEngine, registered_project: dict, faker: Faker
79115
):

0 commit comments

Comments
 (0)