Module: check_mk
Branch: master
Commit: f0327ab01bfea4286cc076db3f52ee5f9c3e3d83
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0327ab01bfea4…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jan 30 17:06:29 2019 +0100
Fixed and simplified path integration test.
Change-Id: I720efa9e522064af505b739cd3ebae2fc78a9324
---
tests/integration/cmk/utils/test_paths.py | 39 +++++++++++--------------------
1 file changed, 13 insertions(+), 26 deletions(-)
diff --git a/tests/integration/cmk/utils/test_paths.py
b/tests/integration/cmk/utils/test_paths.py
index 7205049..3e250af 100644
--- a/tests/integration/cmk/utils/test_paths.py
+++ b/tests/integration/cmk/utils/test_paths.py
@@ -1,36 +1,23 @@
-import pytest
import os
-from cmk.utils.exceptions import MKGeneralException
import cmk.utils.paths
-def _all_path_names():
- import cmk.utils.paths
- names = []
- for name in dir(cmk.utils.paths):
- if name in [ "MKGeneralException", "os" ] or name[0] ==
"_":
- continue
- names.append(name)
- return names
-
-def test_paths_in_site(site):
- for var_name in _all_path_names():
- value = cmk.utils.paths.__dict__[var_name]
- assert value is not None
- assert type(value) == str
- assert value.startswith(site.root)
+def _check_paths(root):
+ for var, value in cmk.utils.paths.__dict__.iteritems():
+ if not var.startswith("_") and var not in ('Path',
'os'):
+ assert isinstance(value, str)
+ assert value.startswith(root)
-def test_no_path_variable_none(monkeypatch):
- monkeypatch.setitem(os.environ, 'OMD_ROOT', '/omd/sites/dingeling')
- reload(cmk.utils.paths)
+def test_paths_in_site(site):
+ _check_paths(site.root)
- for var_name in _all_path_names():
- value = cmk.utils.paths.__dict__[var_name]
- assert value is not None
- assert type(value) == str
- assert value.startswith("/omd/sites/dingeling")
- monkeypatch.undo()
+def test_paths_in_omd_root(monkeypatch):
+ omd_root = '/omd/sites/dingeling'
+ with monkeypatch.context() as m:
+ m.setitem(os.environ, 'OMD_ROOT', omd_root)
+ reload(cmk.utils.paths)
+ _check_paths(omd_root)
reload(cmk.utils.paths)