Module: check_mk
Branch: master
Commit: e1fd17d5734c5be81a2887934032b3109e469e2e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e1fd17d5734c5b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 8 13:42:46 2019 +0200
Made path tests work with new pathlib path
Change-Id: I65d4ae8c9d68df0ef1b1f56e040c0d2513cf4584
---
tests/integration/cmk/gui/test_webapi.py | 1 +
tests/integration/cmk/utils/test_paths.py | 23 +++++++++++++++++------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/tests/integration/cmk/gui/test_webapi.py
b/tests/integration/cmk/gui/test_webapi.py
index 991ce76..031c12c 100644
--- a/tests/integration/cmk/gui/test_webapi.py
+++ b/tests/integration/cmk/gui/test_webapi.py
@@ -319,6 +319,7 @@ def test_write_host_tags(web, site):
"FOLDER_PATH": "/",
"all_hosts": [],
"host_tags": {},
+ "host_labels": {},
"ipaddresses": {},
"host_attributes": {},
}
diff --git a/tests/integration/cmk/utils/test_paths.py
b/tests/integration/cmk/utils/test_paths.py
index 3e250af..7871234 100644
--- a/tests/integration/cmk/utils/test_paths.py
+++ b/tests/integration/cmk/utils/test_paths.py
@@ -1,13 +1,22 @@
import os
+from pathlib2 import Path
import cmk.utils.paths
+pathlib_paths = [
+ "discovered_host_labels_dir",
+]
+
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)
+ if var in pathlib_paths:
+ assert isinstance(value, Path)
+ assert str(value).startswith(root)
+ else:
+ assert isinstance(value, str)
+ assert value.startswith(root)
def test_paths_in_site(site):
@@ -16,8 +25,10 @@ def test_paths_in_site(site):
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)
+ try:
+ with monkeypatch.context() as m:
+ m.setitem(os.environ, 'OMD_ROOT', omd_root)
+ reload(cmk.utils.paths)
+ _check_paths(omd_root)
+ finally:
reload(cmk.utils.paths)
- _check_paths(omd_root)
- reload(cmk.utils.paths)