From be3d7569c5b9a2f81ce02e31516235965cb6bc0f Mon Sep 17 00:00:00 2001
From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de>
Date: Fri, 23 Jun 2023 15:28:21 +0200
Subject: [PATCH] add tests to check creation of the init_file

---
 tests/test_mpsd_software.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/test_mpsd_software.py b/tests/test_mpsd_software.py
index 514c8e5..73ef4b1 100644
--- a/tests/test_mpsd_software.py
+++ b/tests/test_mpsd_software.py
@@ -520,6 +520,21 @@ def test_remove_environment(tmp_path):
     # done in test_install_environment_zlib
 
 
+def test_initialize_environment(tmp_path):
+    """Test that init_file is created as expected."""
+    # test that the init file is created as expected
+    mod.initialize_environment(tmp_path)
+    init_file = tmp_path / mod.config_vars["init_file"]
+
+    assert init_file.exists()
+
+    # test that calling again results in warning and exit code 1
+    with pytest.raises(SystemExit) as pytest_wrapped_e:
+        mod.initialize_environment(tmp_path)
+    assert pytest_wrapped_e.type == SystemExit
+    assert pytest_wrapped_e.value.code == 1
+
+
 def test_interface(tmp_path):
     """Test other things (not implemented yet)."""
     pass
-- 
GitLab