Skip to content

Commit 31569fa

Browse files
committed
fixing tests
1 parent 780ba86 commit 31569fa

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

packages/pytest-simcore/src/pytest_simcore/db_entries_mocks.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def create_registered_user(
3535
) -> Iterator[Callable[..., dict]]:
3636
created_user_ids = []
3737

38-
def creator(**user_kwargs) -> dict[str, Any]:
38+
def _(**user_kwargs) -> dict[str, Any]:
3939
with postgres_db.connect() as con:
4040
# removes all users before continuing
4141
user_config = {
@@ -61,7 +61,7 @@ def creator(**user_kwargs) -> dict[str, Any]:
6161
created_user_ids.append(user["id"])
6262
return dict(user._asdict())
6363

64-
yield creator
64+
yield _
6565

6666
with postgres_db.connect() as con:
6767
con.execute(users.delete().where(users.c.id.in_(created_user_ids)))
@@ -87,7 +87,7 @@ async def create_project(
8787
) -> AsyncIterator[Callable[..., Awaitable[ProjectAtDB]]]:
8888
created_project_ids: list[str] = []
8989

90-
async def creator(
90+
async def _(
9191
user: dict[str, Any],
9292
*,
9393
project_nodes_overrides: dict[str, Any] | None = None,
@@ -141,7 +141,7 @@ async def creator(
141141
created_project_ids.append(f"{inserted_project.uuid}")
142142
return inserted_project
143143

144-
yield creator
144+
yield _
145145

146146
# cleanup
147147
async with sqlalchemy_async_engine.begin() as con:
@@ -157,7 +157,7 @@ async def create_pipeline(
157157
) -> AsyncIterator[Callable[..., Awaitable[dict[str, Any]]]]:
158158
created_pipeline_ids: list[str] = []
159159

160-
async def creator(**pipeline_kwargs) -> dict[str, Any]:
160+
async def _(**pipeline_kwargs) -> dict[str, Any]:
161161
pipeline_config = {
162162
"project_id": f"{uuid4()}",
163163
"dag_adjacency_list": {},
@@ -175,7 +175,7 @@ async def creator(**pipeline_kwargs) -> dict[str, Any]:
175175
created_pipeline_ids.append(new_pipeline["project_id"])
176176
return new_pipeline
177177

178-
yield creator
178+
yield _
179179

180180
# cleanup
181181
async with sqlalchemy_async_engine.begin() as conn:
@@ -192,7 +192,7 @@ async def create_comp_task(
192192
) -> AsyncIterator[Callable[..., Awaitable[dict[str, Any]]]]:
193193
created_task_ids: list[int] = []
194194

195-
async def creator(project_id: ProjectID, **task_kwargs) -> dict[str, Any]:
195+
async def _(project_id: ProjectID, **task_kwargs) -> dict[str, Any]:
196196
task_config = {"project_id": f"{project_id}"} | task_kwargs
197197
async with sqlalchemy_async_engine.begin() as conn:
198198
result = await conn.execute(
@@ -205,7 +205,7 @@ async def creator(project_id: ProjectID, **task_kwargs) -> dict[str, Any]:
205205
created_task_ids.append(new_task["task_id"])
206206
return new_task
207207

208-
yield creator
208+
yield _
209209

210210
# cleanup
211211
async with sqlalchemy_async_engine.begin() as conn:
@@ -224,7 +224,7 @@ def grant_service_access_rights(
224224
"""
225225
created_entries: list[tuple[str, str, int, str]] = []
226226

227-
def creator(
227+
def _(
228228
*,
229229
service_key: str,
230230
service_version: str,
@@ -268,7 +268,7 @@ def creator(
268268
# Convert row to dict
269269
return dict(row._asdict())
270270

271-
yield creator
271+
yield _
272272

273273
# Cleanup all created entries
274274
with postgres_db.begin() as conn:

packages/simcore-sdk/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
pytest_plugins = [
2424
"pytest_simcore.aws_s3_service",
2525
"pytest_simcore.aws_server",
26+
"pytest_simcore.db_entries_mocks",
2627
"pytest_simcore.disk_usage_monitoring",
2728
"pytest_simcore.docker_compose",
2829
"pytest_simcore.docker_swarm",
@@ -66,8 +67,7 @@ def empty_configuration_file() -> Path:
6667
@pytest.fixture
6768
def node_ports_config(
6869
postgres_host_config: PostgresTestConfig, minio_s3_settings_envs: EnvVarsDict
69-
) -> None:
70-
...
70+
) -> None: ...
7171

7272

7373
@pytest.fixture

services/director-v2/tests/unit/with_dbs/test_modules_db_repositories_projects.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,40 +69,40 @@ def workbench() -> dict[str, Any]:
6969

7070

7171
@pytest.fixture()
72-
async def project(
72+
async def with_project(
7373
mock_env: EnvVarsDict,
7474
create_registered_user: Callable[..., dict],
7575
with_product: dict[str, Any],
76-
project: Callable[..., Awaitable[ProjectAtDB]],
76+
create_project: Callable[..., Awaitable[ProjectAtDB]],
7777
workbench: dict[str, Any],
7878
) -> ProjectAtDB:
79-
return await project(create_registered_user(), workbench=workbench)
79+
return await create_project(create_registered_user(), workbench=workbench)
8080

8181

8282
async def test_is_node_present_in_workbench(
83-
initialized_app: FastAPI, project: ProjectAtDB, faker: Faker
83+
initialized_app: FastAPI, with_project: ProjectAtDB, faker: Faker
8484
):
8585
project_repository = get_repository(initialized_app, ProjectsRepository)
8686

87-
for node_uuid in project.workbench:
87+
for node_uuid in with_project.workbench:
8888
assert (
8989
await project_repository.is_node_present_in_workbench(
90-
project_id=project.uuid, node_uuid=NodeID(node_uuid)
90+
project_id=with_project.uuid, node_uuid=NodeID(node_uuid)
9191
)
9292
is True
9393
)
9494

9595
not_existing_node = faker.uuid4(cast_to=None)
96-
assert not_existing_node not in project.workbench
96+
assert not_existing_node not in with_project.workbench
9797
assert (
9898
await project_repository.is_node_present_in_workbench(
99-
project_id=project.uuid, node_uuid=not_existing_node
99+
project_id=with_project.uuid, node_uuid=not_existing_node
100100
)
101101
is False
102102
)
103103

104104
not_existing_project = faker.uuid4(cast_to=None)
105-
assert not_existing_project != project.uuid
105+
assert not_existing_project != with_project.uuid
106106
assert (
107107
await project_repository.is_node_present_in_workbench(
108108
project_id=not_existing_project, node_uuid=not_existing_node
@@ -112,13 +112,13 @@ async def test_is_node_present_in_workbench(
112112

113113

114114
async def test_get_project_id_from_node(
115-
initialized_app: FastAPI, project: ProjectAtDB, faker: Faker
115+
initialized_app: FastAPI, with_project: ProjectAtDB, faker: Faker
116116
):
117117
project_repository = get_repository(initialized_app, ProjectsRepository)
118-
for node_uuid in project.workbench:
118+
for node_uuid in with_project.workbench:
119119
assert (
120120
await project_repository.get_project_id_from_node(NodeID(node_uuid))
121-
== project.uuid
121+
== with_project.uuid
122122
)
123123

124124
not_existing_node_id = faker.uuid4(cast_to=None)

services/director-v2/tests/unit/with_dbs/test_utils_rabbitmq.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,28 @@ def user(create_registered_user: Callable[..., dict]) -> dict:
8484

8585

8686
@pytest.fixture
87-
async def project(
87+
async def with_project(
8888
user: dict[str, Any],
8989
fake_workbench_without_outputs: dict[str, Any],
90-
project: Callable[..., Awaitable[ProjectAtDB]],
90+
create_project: Callable[..., Awaitable[ProjectAtDB]],
9191
with_product: dict[str, Any],
9292
) -> ProjectAtDB:
93-
return await project(user, workbench=fake_workbench_without_outputs)
93+
return await create_project(user, workbench=fake_workbench_without_outputs)
9494

9595

9696
@pytest.fixture
9797
async def tasks(
9898
user: dict[str, Any],
99-
project: ProjectAtDB,
99+
with_project: ProjectAtDB,
100100
fake_workbench_adjacency: dict[str, Any],
101101
create_pipeline: Callable[..., Awaitable[CompPipelineAtDB]],
102102
create_tasks_from_project: Callable[..., Awaitable[list[CompTaskAtDB]]],
103103
) -> list[CompTaskAtDB]:
104104
await create_pipeline(
105-
project_id=f"{project.uuid}",
105+
project_id=f"{with_project.uuid}",
106106
dag_adjacency_list=fake_workbench_adjacency,
107107
)
108-
comp_tasks = await create_tasks_from_project(user, project)
108+
comp_tasks = await create_tasks_from_project(user, with_project)
109109
assert len(comp_tasks) > 0
110110
return comp_tasks
111111

@@ -162,7 +162,7 @@ async def test_publish_service_stopped_metrics(
162162
async def test_publish_service_resource_tracking_started(
163163
create_rabbitmq_client: Callable[[str], RabbitMQClient],
164164
user: dict[str, Any],
165-
project: ProjectAtDB,
165+
with_project: ProjectAtDB,
166166
simcore_user_agent: str,
167167
tasks: list[CompTaskAtDB],
168168
mocked_message_parser: mock.AsyncMock,
@@ -191,10 +191,10 @@ async def test_publish_service_resource_tracking_started(
191191
simcore_user_agent=simcore_user_agent,
192192
user_id=user["id"],
193193
user_email=faker.email(),
194-
project_id=project.uuid,
195-
project_name=project.name,
194+
project_id=with_project.uuid,
195+
project_name=with_project.name,
196196
node_id=random_task.node_id,
197-
node_name=project.workbench[NodeIDStr(f"{random_task.node_id}")].label,
197+
node_name=with_project.workbench[NodeIDStr(f"{random_task.node_id}")].label,
198198
parent_project_id=None,
199199
parent_node_id=None,
200200
root_parent_project_id=None,

0 commit comments

Comments
 (0)