Skip to content

Commit

Permalink
Update test_project_apply_missing_user_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Sep 19, 2024
1 parent 0341b62 commit 4322209
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions tests/v2/03_api/test_api_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 4322209

Please sign in to comment.