From 43dbbb95f5711c789e7bbc17d215825551e9c2d3 Mon Sep 17 00:00:00 2001
From: lukas leufen <l.leufen@fz-juelich.de>
Date: Fri, 13 Mar 2020 09:46:37 +0100
Subject: [PATCH] fixed test

---
 src/run_modules/pre_processing.py        | 3 ++-
 test/test_modules/test_pre_processing.py | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/run_modules/pre_processing.py b/src/run_modules/pre_processing.py
index ee764174..1f84db14 100644
--- a/src/run_modules/pre_processing.py
+++ b/src/run_modules/pre_processing.py
@@ -125,11 +125,12 @@ class PreProcessing(RunEnvironment):
         :param kwargs: positional parameters for the DataGenerator class (e.g. `start`, `interpolate_method`,
             `window_lead_time`).
         :param all_stations: All stations to check.
+        :param name: name to display in the logging info message
         :return: Corrected list containing only valid station IDs.
         """
         t_outer = TimeTracking()
         t_inner = TimeTracking(start=False)
-        logging.info(f"check valid stations started{' (%s)' % name if name else name}")
+        logging.info(f"check valid stations started{' (%s)' % name if name else ''}")
         valid_stations = []
 
         # all required arguments of the DataGenerator can be found in args, positional arguments in args and kwargs
diff --git a/test/test_modules/test_pre_processing.py b/test/test_modules/test_pre_processing.py
index d58cbd41..7fbf202d 100644
--- a/test/test_modules/test_pre_processing.py
+++ b/test/test_modules/test_pre_processing.py
@@ -81,16 +81,18 @@ class TestPreProcessing:
             data_store.get("generator", "general")
         assert data_store.get("stations", "general.awesome") == ['DEBW107', 'DEBY081', 'DEBW013', 'DEBW076', 'DEBW087']
 
-    def test_check_valid_stations(self, caplog, obj_with_exp_setup):
+    @pytest.mark.parametrize("name", (None, "tester"))
+    def test_check_valid_stations(self, caplog, obj_with_exp_setup, name):
         pre = obj_with_exp_setup
         caplog.set_level(logging.INFO)
         args = pre.data_store.create_args_dict(DEFAULT_ARGS_LIST)
         kwargs = pre.data_store.create_args_dict(DEFAULT_KWARGS_LIST)
         stations = pre.data_store.get("stations", "general")
-        valid_stations = pre.check_valid_stations(args, kwargs, stations)
+        valid_stations = pre.check_valid_stations(args, kwargs, stations, name=name)
         assert len(valid_stations) < len(stations)
         assert valid_stations == stations[:-1]
-        assert caplog.record_tuples[0] == ('root', 20, 'check valid stations started')
+        expected = 'check valid stations started (tester)' if name else 'check valid stations started'
+        assert caplog.record_tuples[0] == ('root', 20, expected)
         assert caplog.record_tuples[-1] == ('root', 20, PyTestRegex(r'run for \d+:\d+:\d+ \(hh:mm:ss\) to check 6 '
                                                                     r'station\(s\). Found 5/6 valid stations.'))
 
-- 
GitLab