From 260153607be0c839b92c432048502619267398de Mon Sep 17 00:00:00 2001 From: xjules Date: Wed, 25 Oct 2023 12:59:54 +0200 Subject: [PATCH] Add test for wrong config types --- tests/unit_tests/config/test_queue_config.py | 24 +++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/unit_tests/config/test_queue_config.py b/tests/unit_tests/config/test_queue_config.py index eb1cd5277e7..b61f875d066 100644 --- a/tests/unit_tests/config/test_queue_config.py +++ b/tests/unit_tests/config/test_queue_config.py @@ -8,12 +8,7 @@ import pytest from hypothesis import given -from ert.config import ( - ConfigValidationError, - ErtConfig, - QueueConfig, - QueueSystem, -) +from ert.config import ConfigValidationError, ErtConfig, QueueConfig, QueueSystem from ert.job_queue import Driver @@ -208,3 +203,20 @@ def test_initializing_empty_config_values(queue_system, queue_system_option): assert driver.get_option("MAX_RUNNING") == "0" for options in config_object.queue_config.queue_options[queue_system]: assert isinstance(options, tuple) + + +@pytest.mark.usefixtures("use_tmpdir") +@pytest.mark.parametrize( + "queue_system, queue_system_option", + [("LSF", "LSF_SERVER")], +) +def test_wrong_config_types(queue_system, queue_system_option): + filename = "config.ert" + with open(filename, "w", encoding="utf-8") as f: + f.write("NUM_REALIZATIONS 1\n") + f.write(f"QUEUE_SYSTEM {queue_system}\n") + f.write(f"QUEUE_OPTION {queue_system} {queue_system_option}\n") + f.write(f"QUEUE_OPTION {queue_system} SUBMIT_SLEEP nan\n") + + with pytest.raises(ConfigValidationError, match="is not valid positive integer"): + ErtConfig.from_file(filename)