From 7b810736c7856fea325a3035248528b4a5fcedd2 Mon Sep 17 00:00:00 2001 From: Carlos Marques Date: Tue, 3 Dec 2024 16:30:30 -0300 Subject: [PATCH] Add unit tests for empty job name --- tests/ert/unit_tests/scheduler/test_lsf_driver.py | 7 +++++++ tests/ert/unit_tests/scheduler/test_openpbs_driver.py | 7 +++++++ tests/ert/unit_tests/scheduler/test_slurm_driver.py | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/tests/ert/unit_tests/scheduler/test_lsf_driver.py b/tests/ert/unit_tests/scheduler/test_lsf_driver.py index 088575ad618..369356b2f9f 100644 --- a/tests/ert/unit_tests/scheduler/test_lsf_driver.py +++ b/tests/ert/unit_tests/scheduler/test_lsf_driver.py @@ -1167,6 +1167,13 @@ async def test_submit_with_resource_requirement_with_bsub_capture(): assert "hname" not in Path("captured_bsub_args").read_text(encoding="utf-8") +@pytest.mark.usefixtures("capturing_bsub") +async def test_empty_job_name(): + driver = LsfDriver() + await driver.submit(0, "/bin/sleep") + assert " -J sleep " in Path("captured_bsub_args").read_text(encoding="utf-8") + + @pytest.mark.integration_test @pytest.mark.usefixtures("use_tmpdir") async def test_submit_with_num_cpu(pytestconfig, job_name): diff --git a/tests/ert/unit_tests/scheduler/test_openpbs_driver.py b/tests/ert/unit_tests/scheduler/test_openpbs_driver.py index 41f99b61c2f..f8745f54f6d 100644 --- a/tests/ert/unit_tests/scheduler/test_openpbs_driver.py +++ b/tests/ert/unit_tests/scheduler/test_openpbs_driver.py @@ -165,6 +165,13 @@ async def test_job_name(): assert " -Nsleepy " in Path("captured_qsub_args").read_text(encoding="utf-8") +@pytest.mark.usefixtures("capturing_qsub") +async def test_empty_job_name(): + driver = OpenPBSDriver() + await driver.submit(0, "/bin/sleep") + assert " -Nsleep " in Path("captured_qsub_args").read_text(encoding="utf-8") + + @pytest.mark.usefixtures("capturing_qsub") async def test_job_name_with_prefix(): driver = OpenPBSDriver(job_prefix="pre_") diff --git a/tests/ert/unit_tests/scheduler/test_slurm_driver.py b/tests/ert/unit_tests/scheduler/test_slurm_driver.py index b39875b2e67..16c6dfb783a 100644 --- a/tests/ert/unit_tests/scheduler/test_slurm_driver.py +++ b/tests/ert/unit_tests/scheduler/test_slurm_driver.py @@ -144,6 +144,15 @@ async def test_project_code_is_set(project_code): ) +@pytest.mark.usefixtures("capturing_sbatch") +async def test_empty_job_name(): + driver = SlurmDriver() + await driver.submit(0, "/bin/sleep") + assert "--job-name=sleep" in Path("captured_sbatch_args").read_text( + encoding="utf-8" + ) + + @pytest.mark.usefixtures("capturing_sbatch") @given(max_runtime=st.floats(min_value=1, max_value=999999999)) async def test_max_runtime_is_properly_formatted(max_runtime):