From 432220944ee93995c356b8b1933c31915eaccdaa Mon Sep 17 00:00:00 2001 From: Tommaso Comparin <3862206+tcompa@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:05:15 +0200 Subject: [PATCH] Update test_project_apply_missing_user_attributes --- tests/v2/03_api/test_api_job.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/v2/03_api/test_api_job.py b/tests/v2/03_api/test_api_job.py index 93f77ce635..c28d5b7f77 100644 --- a/tests/v2/03_api/test_api_job.py +++ b/tests/v2/03_api/test_api_job.py @@ -182,22 +182,20 @@ async def test_project_apply_missing_user_attributes( override_settings_factory, ): """ - When using the slurm backend, user.slurm_user and user.cache_dir become - required attributes. If they are missing, the apply endpoint fails with a - 422 error. + When using the slurm backend, some user.settings attributes are required. + If they are missing, the apply endpoint fails with a 422 error. """ override_settings_factory(FRACTAL_RUNNER_BACKEND="slurm") - async with MockCurrentUser(user_kwargs=dict(is_verified=True)) as user: - # Make sure that user.cache_dir was not set - debug(user) - assert user.cache_dir is None + async with MockCurrentUser( + user_kwargs=dict(is_verified=True), + user_settings_dict=dict(something="else"), + ) as user: # Create project, datasets, workflow, task, workflowtask project = await project_factory_v2(user) dataset = await dataset_factory_v2(project_id=project.id, name="ds") - workflow = await workflow_factory_v2(project_id=project.id) task = await task_factory_v2() await _workflow_insert_task( @@ -212,10 +210,14 @@ async def test_project_apply_missing_user_attributes( ) debug(res.json()) assert res.status_code == 422 - assert "user.cache_dir=None" in res.json()["detail"] + assert "User settings are not valid" in res.json()["detail"] + assert ( + "validation errors for SlurmSudoUserSettings" + in res.json()["detail"] + ) - user.cache_dir = "/tmp" - user.slurm_user = None + user.settings.cache_dir = "/tmp" + user.settings.slurm_user = None await db.commit() res = await client.post( @@ -225,7 +227,11 @@ async def test_project_apply_missing_user_attributes( ) debug(res.json()) assert res.status_code == 422 - assert "user.slurm_user=None" in res.json()["detail"] + assert "User settings are not valid" in res.json()["detail"] + assert ( + "validation error for SlurmSudoUserSettings" + in res.json()["detail"] + ) async def test_project_apply_workflow_subset(