From a4721854fb319435da9071a8140050ea97060b3f Mon Sep 17 00:00:00 2001 From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de> Date: Tue, 27 Jun 2023 17:10:41 +0200 Subject: [PATCH] add tests for root_dir --- tests/test_mpsd_software.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_mpsd_software.py b/tests/test_mpsd_software.py index 3ebd1fd..91950f6 100644 --- a/tests/test_mpsd_software.py +++ b/tests/test_mpsd_software.py @@ -539,6 +539,28 @@ def test_initialize_environment(tmp_path): assert pytest_wrapped_e.value.code == 1 +def test_get_root_dir(tmp_path): + """Test that the root directory is correct.""" + with mod.os_chdir(tmp_path): + # test that function exists with error 1 if root dir doesn't exist + with pytest.raises(SystemExit) as pytest_wrapped_e: + mod.get_root_dir() + assert pytest_wrapped_e.type == SystemExit + assert pytest_wrapped_e.value.code == 1 + + # test that initialize_environment creates the root dir + mod.initialize_environment(tmp_path) + root_dir = mod.get_root_dir() + assert root_dir == tmp_path + + # test that root_dir from paret is detected correctly + sub_dir = tmp_path / "sub_dir" + sub_dir.mkdir() + with mod.os_chdir(sub_dir): + root_dir = mod.get_root_dir() + assert root_dir == tmp_path + + def test_interface(tmp_path): """Test other things (not implemented yet).""" pass -- GitLab