From 5145b063744a85f6d0f86debe3c99874174346df Mon Sep 17 00:00:00 2001
From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de>
Date: Thu, 8 Jun 2023 13:12:25 +0200
Subject: [PATCH] fix typo and tests

---
 mpsd-software-environment.py |  1 +
 tests.py                     | 37 ++++++++++++++++--------------------
 2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py
index c208654..6fcba2b 100755
--- a/mpsd-software-environment.py
+++ b/mpsd-software-environment.py
@@ -101,6 +101,7 @@ def create_log_file_names(
         log_template = config_vars["installer_log_template"]
 
     return log_template.substitute(
+            mpsd_release=mpsd_release,
             mpsd_microarch=mpsd_microarch,
             date=date,
             action=action,
diff --git a/tests.py b/tests.py
index 01be0fd..f364eb2 100644
--- a/tests.py
+++ b/tests.py
@@ -383,51 +383,46 @@ def test_metadata_logging(tmp_path):
     assert len(read_dict) == len(keys)
 
 
-@pytest.mark.skip(
-    reason="This function is redundant in the next version of the script."
-)
+
 def test_create_log_file_names():
     """Test that the log file names are created correctly."""
-    pass
     create_log_file_names = mod.create_log_file_names
     mpsd_release = "dev-23a"
     mpsd_microarch = "sandybridge"
     date = datetime.datetime.now().replace(microsecond=0).isoformat()
     action = "install"
     toolchain = "foss2021a"
-    # test for correct action and toolchain
-    installer_log_file, build_log_file = create_log_file_names(
+    # test build_log_file_name  generation
+    build_log_file_name = create_log_file_names(
         mpsd_microarch=mpsd_microarch,
         mpsd_release=mpsd_release,
         date=date,
         action=action,
         toolchain=toolchain,
     )
-    assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_{action}.log"
     assert (
-        build_log_file
-        == f"{mpsd_release}_{mpsd_microarch}_{date}_{toolchain}_{action}.log"
+        build_log_file_name
+        == f"{mpsd_release}_{mpsd_microarch}_{date}_BUILD_{toolchain}_{action}.log"
     )
-    # test no build log file for incorrect action
-    installer_log_file, build_log_file = create_log_file_names(
+    installer_log_file_name = create_log_file_names(
         mpsd_microarch=mpsd_microarch,
         mpsd_release=mpsd_release,
         date=date,
-        action="status",
-        toolchain=toolchain,
+        action=action,
     )
-    assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_status.log"
-    assert build_log_file is None
-    # test no build log file for incorrect toolchain
-    installer_log_file, build_log_file = create_log_file_names(
+    assert (
+        installer_log_file_name
+        == f"{mpsd_release}_{mpsd_microarch}_{date}_APEX_{action}.log"
+    )
+    # test no build log file for incorrect action
+    build_log_file_name = create_log_file_names(
         mpsd_microarch=mpsd_microarch,
         mpsd_release=mpsd_release,
         date=date,
-        action="reinstall",
-        toolchain=None,
+        action="status",
+        toolchain=toolchain,
     )
-    assert installer_log_file == f"{mpsd_release}_{mpsd_microarch}_{date}_reinstall.log"
-    assert build_log_file is None
+    assert build_log_file_name is None
 
 
 def test_interface(tmp_path):
-- 
GitLab