From fd4093991cc36bce8e7684f5cf071c30c809e607 Mon Sep 17 00:00:00 2001 From: Carlos Marques Date: Tue, 3 Dec 2024 14:28:00 -0300 Subject: [PATCH] Add unit tests for conda activation script --- .../unit_tests/config/test_queue_config.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ert/unit_tests/config/test_queue_config.py b/tests/ert/unit_tests/config/test_queue_config.py index bfa26641652..72f3103f2e3 100644 --- a/tests/ert/unit_tests/config/test_queue_config.py +++ b/tests/ert/unit_tests/config/test_queue_config.py @@ -522,3 +522,26 @@ def test_default_activate_script_generation(expected, monkeypatch, venv): monkeypatch.delenv("VIRTUAL_ENV", raising=False) options = QueueOptions(name="local") assert options.activate_script == expected + + +@pytest.mark.parametrize( + "env, expected", + [ + ("my_env", 'eval "$(conda shell.bash hook)" && conda activate my_env'), + ], +) +def test_conda_activate_script_generation(expected, monkeypatch, env): + monkeypatch.setenv("CONDA_ENV", env) + options = QueueOptions(name="local") + assert options.activate_script == expected + + +@pytest.mark.parametrize( + "env, expected", + [("my_env", "source my_env/bin/activate")], +) +def test_multiple_activate_script_generation(expected, monkeypatch, env): + monkeypatch.setenv("VIRTUAL_ENV", env) + monkeypatch.setenv("CONDA_ENV", env) + options = QueueOptions(name="local") + assert options.activate_script == expected