Skip to content

Commit 0fc59fa

Browse files
committed
rename engine fixtures
1 parent 701b14d commit 0fc59fa

File tree

10 files changed

+51
-51
lines changed

10 files changed

+51
-51
lines changed

packages/postgres-database/tests/products/test_models_products.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727

2828
async def test_load_products(
29-
pg_engine: Engine, make_products_table: Callable, products_regex: dict
29+
aiopg_engine: Engine, make_products_table: Callable, products_regex: dict
3030
):
3131
exclude = {
3232
products.c.created,
3333
products.c.modified,
3434
}
3535

36-
async with pg_engine.acquire() as conn:
36+
async with aiopg_engine.acquire() as conn:
3737
await make_products_table(conn)
3838

3939
stmt = sa.select(*[c for c in products.columns if c not in exclude])
@@ -49,14 +49,14 @@ async def test_load_products(
4949

5050

5151
async def test_jinja2_templates_table(
52-
pg_engine: Engine, osparc_simcore_services_dir: Path
52+
aiopg_engine: Engine, osparc_simcore_services_dir: Path
5353
):
5454
templates_common_dir = (
5555
osparc_simcore_services_dir
5656
/ "web/server/src/simcore_service_webserver/templates/common"
5757
)
5858

59-
async with pg_engine.acquire() as conn:
59+
async with aiopg_engine.acquire() as conn:
6060
templates = []
6161
# templates table
6262
for p in templates_common_dir.glob("*.jinja2"):
@@ -135,7 +135,7 @@ async def test_jinja2_templates_table(
135135

136136

137137
async def test_insert_select_product(
138-
pg_engine: Engine,
138+
aiopg_engine: Engine,
139139
):
140140
osparc_product = {
141141
"name": "osparc",
@@ -174,7 +174,7 @@ async def test_insert_select_product(
174174

175175
print(json.dumps(osparc_product))
176176

177-
async with pg_engine.acquire() as conn:
177+
async with aiopg_engine.acquire() as conn:
178178
# writes
179179
stmt = (
180180
pg_insert(products)

packages/postgres-database/tests/products/test_utils_products.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919
)
2020

2121

22-
async def test_default_product(pg_engine: Engine, make_products_table: Callable):
23-
async with pg_engine.acquire() as conn:
22+
async def test_default_product(aiopg_engine: Engine, make_products_table: Callable):
23+
async with aiopg_engine.acquire() as conn:
2424
await make_products_table(conn)
2525
default_product = await get_default_product_name(conn)
2626
assert default_product == "s4l"
2727

2828

2929
@pytest.mark.parametrize("pg_sa_engine", ["sqlModels"], indirect=True)
30-
async def test_default_product_undefined(pg_engine: Engine):
31-
async with pg_engine.acquire() as conn:
30+
async def test_default_product_undefined(aiopg_engine: Engine):
31+
async with aiopg_engine.acquire() as conn:
3232
with pytest.raises(ValueError):
3333
await get_default_product_name(conn)
3434

3535

3636
async def test_get_or_create_group_product(
37-
pg_engine: Engine, make_products_table: Callable
37+
aiopg_engine: Engine, make_products_table: Callable
3838
):
39-
async with pg_engine.acquire() as conn:
39+
async with aiopg_engine.acquire() as conn:
4040
await make_products_table(conn)
4141

4242
async for product_row in await conn.execute(
@@ -105,13 +105,13 @@ async def test_get_or_create_group_product(
105105
reason="Not relevant. Will review in https://github.com/ITISFoundation/osparc-simcore/issues/3754"
106106
)
107107
async def test_get_or_create_group_product_concurrent(
108-
pg_engine: Engine, make_products_table: Callable
108+
aiopg_engine: Engine, make_products_table: Callable
109109
):
110-
async with pg_engine.acquire() as conn:
110+
async with aiopg_engine.acquire() as conn:
111111
await make_products_table(conn)
112112

113113
async def _auto_create_products_groups():
114-
async with pg_engine.acquire() as conn:
114+
async with aiopg_engine.acquire() as conn:
115115
async for product_row in await conn.execute(
116116
sa.select(products.c.name, products.c.group_id).order_by(
117117
products.c.priority

packages/postgres-database/tests/projects/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717

1818
@pytest.fixture
19-
async def user(pg_engine: Engine) -> RowProxy:
19+
async def user(aiopg_engine: Engine) -> RowProxy:
2020
_USERNAME = f"{__name__}.me"
2121
# some user
22-
async with pg_engine.acquire() as conn:
22+
async with aiopg_engine.acquire() as conn:
2323
result: ResultProxy | None = await conn.execute(
2424
users.insert().values(**random_user(name=_USERNAME)).returning(users)
2525
)
@@ -32,10 +32,10 @@ async def user(pg_engine: Engine) -> RowProxy:
3232

3333

3434
@pytest.fixture
35-
async def project(pg_engine: Engine, user: RowProxy) -> RowProxy:
35+
async def project(aiopg_engine: Engine, user: RowProxy) -> RowProxy:
3636
_PARENT_PROJECT_NAME = f"{__name__}.parent"
3737
# a user's project
38-
async with pg_engine.acquire() as conn:
38+
async with aiopg_engine.acquire() as conn:
3939
result: ResultProxy | None = await conn.execute(
4040
projects.insert()
4141
.values(**random_project(prj_owner=user.id, name=_PARENT_PROJECT_NAME))
@@ -50,6 +50,6 @@ async def project(pg_engine: Engine, user: RowProxy) -> RowProxy:
5050

5151

5252
@pytest.fixture
53-
async def conn(pg_engine: Engine) -> AsyncIterable[SAConnection]:
54-
async with pg_engine.acquire() as conn:
53+
async def conn(aiopg_engine: Engine) -> AsyncIterable[SAConnection]:
54+
async with aiopg_engine.acquire() as conn:
5555
yield conn

packages/postgres-database/tests/test_classifiers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def classifiers_bundle(web_client_resource_folder: Path) -> dict:
3838

3939

4040
async def test_operations_on_group_classifiers(
41-
pg_engine: Engine, classifiers_bundle: dict
41+
aiopg_engine: Engine, classifiers_bundle: dict
4242
):
4343
# NOTE: mostly for TDD
44-
async with pg_engine.acquire() as conn:
44+
async with aiopg_engine.acquire() as conn:
4545
# creates a group
4646
stmt = (
4747
groups.insert()

packages/postgres-database/tests/test_clusters.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717

1818
@pytest.fixture
19-
async def user_id(pg_engine: Engine) -> AsyncIterable[int]:
20-
async with pg_engine.acquire() as conn:
19+
async def user_id(aiopg_engine: Engine) -> AsyncIterable[int]:
20+
async with aiopg_engine.acquire() as conn:
2121
# a 'me' user
2222
uid = await conn.scalar(
2323
users.insert().values(**(random_user())).returning(users.c.id)
2424
)
2525
assert uid is not None
2626
yield uid
2727
# cleanup
28-
async with pg_engine.acquire() as conn:
28+
async with aiopg_engine.acquire() as conn:
2929
# a 'me' user
3030
uid = await conn.execute(users.delete().where(users.c.id == uid))
3131

3232

3333
@pytest.fixture
34-
async def user_group_id(pg_engine: Engine, user_id: int) -> int:
35-
async with pg_engine.acquire() as conn:
34+
async def user_group_id(aiopg_engine: Engine, user_id: int) -> int:
35+
async with aiopg_engine.acquire() as conn:
3636
primary_gid = await conn.scalar(
3737
sa.select(users.c.primary_gid).where(users.c.id == user_id)
3838
)
@@ -64,34 +64,34 @@ async def test_can_create_cluster_with_owner(
6464

6565

6666
async def test_cannot_remove_owner_that_owns_cluster(
67-
pg_engine: Engine,
67+
aiopg_engine: Engine,
6868
user_id: int,
6969
user_group_id: int,
7070
create_fake_cluster: Callable[..., Awaitable[int]],
7171
):
7272
cluster_id = await create_fake_cluster(owner=user_group_id)
7373
# now try removing the user
74-
async with pg_engine.acquire() as conn:
74+
async with aiopg_engine.acquire() as conn:
7575
with pytest.raises(ForeignKeyViolation):
7676
await conn.execute(users.delete().where(users.c.id == user_id))
7777

7878
# now remove the cluster
79-
async with pg_engine.acquire() as conn:
79+
async with aiopg_engine.acquire() as conn:
8080
await conn.execute(clusters.delete().where(clusters.c.id == cluster_id))
8181

8282
# removing the user should work now
83-
async with pg_engine.acquire() as conn:
83+
async with aiopg_engine.acquire() as conn:
8484
await conn.execute(users.delete().where(users.c.id == user_id))
8585

8686

8787
async def test_cluster_owner_has_all_rights(
88-
pg_engine: Engine,
88+
aiopg_engine: Engine,
8989
user_group_id: int,
9090
create_fake_cluster: Callable[..., Awaitable[int]],
9191
):
9292
cluster_id = await create_fake_cluster(owner=user_group_id)
9393

94-
async with pg_engine.acquire() as conn:
94+
async with aiopg_engine.acquire() as conn:
9595
result: ResultProxy = await conn.execute(
9696
cluster_to_groups.select().where(
9797
cluster_to_groups.c.cluster_id == cluster_id

packages/postgres-database/tests/test_comp_tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
@pytest.fixture()
22-
async def db_connection(pg_engine: Engine) -> SAConnection:
23-
async with pg_engine.acquire() as conn:
22+
async def db_connection(aiopg_engine: Engine) -> SAConnection:
23+
async with aiopg_engine.acquire() as conn:
2424
yield conn
2525

2626

packages/postgres-database/tests/test_delete_projects_and_users.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616

1717
@pytest.fixture
18-
async def engine(pg_engine: Engine):
19-
async with pg_engine.acquire() as conn:
18+
async def engine(aiopg_engine: Engine):
19+
async with aiopg_engine.acquire() as conn:
2020
await conn.execute(users.insert().values(**random_user(name="A")))
2121
await conn.execute(users.insert().values(**random_user()))
2222
await conn.execute(users.insert().values(**random_user()))
@@ -27,7 +27,7 @@ async def engine(pg_engine: Engine):
2727
with pytest.raises(ForeignKeyViolation):
2828
await conn.execute(projects.insert().values(**random_project(prj_owner=4)))
2929

30-
return pg_engine
30+
return aiopg_engine
3131

3232

3333
@pytest.mark.skip(reason="sandbox for dev purposes")

packages/postgres-database/tests/test_services_consume_filetypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ async def _make(connection: SAConnection):
5959

6060
@pytest.fixture
6161
async def connection(
62-
pg_engine: sa.engine.Engine, connection: SAConnection, make_table: Callable
62+
aiopg_engine: sa.engine.Engine, connection: SAConnection, make_table: Callable
6363
):
64-
assert pg_engine
64+
assert aiopg_engine
6565
# NOTE: do not remove th pg_engine, or the test will fail as pytest
6666
# cannot set the parameters in the fixture
6767

packages/postgres-database/tests/test_utils_aiopg_orm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717

1818
@pytest.fixture
19-
async def fake_scicrunch_ids(pg_engine: Engine) -> list[str]:
19+
async def fake_scicrunch_ids(aiopg_engine: Engine) -> list[str]:
2020
row1 = {"rrid": "RRID:foo", "name": "foo", "description": "fooing"}
2121
row2 = {"rrid": "RRID:bar", "name": "bar", "description": "barring"}
2222

2323
row_ids = []
24-
async with pg_engine.acquire() as conn:
24+
async with aiopg_engine.acquire() as conn:
2525
for row in (row1, row2):
2626
row_id = await conn.scalar(
2727
scicrunch_resources.insert()
@@ -35,7 +35,7 @@ async def fake_scicrunch_ids(pg_engine: Engine) -> list[str]:
3535

3636

3737
@pytest.fixture()
38-
async def scicrunch_orm(pg_engine: Engine) -> Iterator[BaseOrm[str]]:
38+
async def scicrunch_orm(aiopg_engine: Engine) -> Iterator[BaseOrm[str]]:
3939
# This is a table without dependencies and therefore easy to use as fixture
4040
class ScicrunchOrm(BaseOrm[str]):
4141
def __init__(self, connection: SAConnection):
@@ -46,7 +46,7 @@ def __init__(self, connection: SAConnection):
4646
writeonce={"rrid"},
4747
)
4848

49-
async with pg_engine.acquire() as conn:
49+
async with aiopg_engine.acquire() as conn:
5050
orm_obj = ScicrunchOrm(conn)
5151
yield orm_obj
5252

packages/postgres-database/tests/test_utils_projects_nodes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async def test_delete_project_delete_all_nodes(
309309

310310
@pytest.mark.parametrize("num_concurrent_workflows", [1, 250])
311311
async def test_multiple_creation_deletion_of_nodes(
312-
pg_engine: Engine,
312+
aiopg_engine: Engine,
313313
registered_user: RowProxy,
314314
create_fake_project: Callable[..., Awaitable[RowProxy]],
315315
create_fake_projects_node: Callable[..., ProjectNodeCreate],
@@ -318,7 +318,7 @@ async def test_multiple_creation_deletion_of_nodes(
318318
NUM_NODES = 11
319319

320320
async def _workflow() -> None:
321-
async with pg_engine.acquire() as connection:
321+
async with aiopg_engine.acquire() as connection:
322322
project = await create_fake_project(connection, registered_user)
323323
projects_nodes_repo = ProjectNodesRepo(project_uuid=project.uuid)
324324

@@ -341,7 +341,7 @@ async def _workflow() -> None:
341341

342342

343343
async def test_get_project_id_from_node_id(
344-
pg_engine: Engine,
344+
aiopg_engine: Engine,
345345
connection: SAConnection,
346346
projects_nodes_repo: ProjectNodesRepo,
347347
registered_user: RowProxy,
@@ -351,7 +351,7 @@ async def test_get_project_id_from_node_id(
351351
NUM_NODES = 11
352352

353353
async def _workflow() -> dict[uuid.UUID, list[uuid.UUID]]:
354-
async with pg_engine.acquire() as connection:
354+
async with aiopg_engine.acquire() as connection:
355355
project = await create_fake_project(connection, registered_user)
356356
projects_nodes_repo = ProjectNodesRepo(project_uuid=project.uuid)
357357

@@ -379,7 +379,7 @@ async def _workflow() -> dict[uuid.UUID, list[uuid.UUID]]:
379379

380380

381381
async def test_get_project_id_from_node_id_raises_for_invalid_node_id(
382-
pg_engine: Engine,
382+
aiopg_engine: Engine,
383383
connection: SAConnection,
384384
projects_nodes_repo: ProjectNodesRepo,
385385
faker: Faker,
@@ -393,7 +393,7 @@ async def test_get_project_id_from_node_id_raises_for_invalid_node_id(
393393

394394

395395
async def test_get_project_id_from_node_id_raises_if_multiple_projects_with_same_node_id_exist(
396-
pg_engine: Engine,
396+
aiopg_engine: Engine,
397397
connection: SAConnection,
398398
projects_nodes_repo: ProjectNodesRepo,
399399
registered_user: RowProxy,

0 commit comments

Comments
 (0)