From 119fc5f5bb9aff1bab48160fadc54a3105162e43 Mon Sep 17 00:00:00 2001
From: lukas leufen <l.leufen@fz-juelich.de>
Date: Tue, 4 Feb 2020 15:27:38 +0100
Subject: [PATCH] added test for new timetracking feature

---
 test/test_helpers.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/test/test_helpers.py b/test/test_helpers.py
index c909960b..463007dc 100644
--- a/test/test_helpers.py
+++ b/test/test_helpers.py
@@ -109,10 +109,18 @@ class TestTimeTracking:
         duration = t.stop(get_duration=True)
         assert duration == t.duration()
 
+    def test_enter_exit(self, caplog):
+        caplog.set_level(logging.INFO)
+        with TimeTracking() as t:
+            assert t.start is not None
+            assert t.end is None
+        expression = PyTestRegex(r"undefined job finished after \d+:\d+:\d+ \(hh:mm:ss\)")
+        assert caplog.record_tuples[-1] == ('root', 20, expression)
+
 
 class TestPrepareHost:
 
-    @mock.patch("socket.gethostname", side_effect=["linux-gzsx", "ZAM144", "zam347", "jrtest", "jwtest"])
+    @mock.patch("socket.gethostname", side_effect=["linux-aa9b", "ZAM144", "zam347", "jrtest", "jwtest"])
     @mock.patch("os.getlogin", return_value="testUser")
     @mock.patch("os.path.exists", return_value=True)
     def test_prepare_host(self, mock_host, mock_user, mock_path):
@@ -134,10 +142,10 @@ class TestPrepareHost:
             prepare_host()
         assert "unknown host 'NotExistingHostName'" in e.value.args[0]
         if "runner-6HmDp9Qd-project-2411-concurrent" not in platform.node():
-            mock_host.return_value = "linux-gzsx"
+            mock_host.return_value = "linux-aa9b"
             with pytest.raises(NotADirectoryError) as e:
                 prepare_host()
-            assert "does not exist for host 'linux-gzsx'" in e.value.args[0]
+            assert "does not exist for host 'linux-aa9b'" in e.value.args[0]
 
 
 class TestSetExperimentName:
-- 
GitLab