Module: check_mk
Branch: master
Commit: e250ae07f6b20813c1ac6b9f3e7cb5894baebc09
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e250ae07f6b208…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jan 16 15:21:54 2019 +0100
Improved get_inventory integration test.
Change-Id: Ib334b6df50547d8c440ab35bc89589d3d4de826b
---
tests/integration/cmk/gui/test_webapi.py | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/tests/integration/cmk/gui/test_webapi.py
b/tests/integration/cmk/gui/test_webapi.py
index 6e7eee5..ae95a23 100644
--- a/tests/integration/cmk/gui/test_webapi.py
+++ b/tests/integration/cmk/gui/test_webapi.py
@@ -762,14 +762,31 @@ def test_get_graph_hover(web, graph_test_config):
def test_get_inventory(web):
+ host_name = "test-host"
+ inventory_dir = "var/check_mk/inventory"
try:
- web.add_host(
- "test-host", attributes={
- "ipaddress": "127.0.0.1",
- })
+ web.add_host(host_name, attributes={"ipaddress":
"127.0.0.1"})
+ # NOTE: Deleting the host deletes the file, too.
+ web.site.makedirs(inventory_dir)
+ web.site.write_file(
+ os.path.join(inventory_dir, host_name),
+ "{'hardware': {'memory': {'ram': 10000,
'foo': 1}, 'blubb': 42}}")
+
+ inv = web.get_inventory([host_name])
+ assert inv[host_name] == {
+ u'hardware': {
+ u'memory': {
+ u'foo': 1,
+ u'ram': 10000
+ },
+ u'blubb': 42
+ }
+ }
- inv = web.get_inventory(["test-host"])
+ inv = web.get_inventory([host_name], paths=['.hardware.memory.'])
+ assert inv[host_name] == {u'hardware': {u'memory':
{u'foo': 1, u'ram': 10000}}}
- assert inv["test-host"] == {}
+ inv = web.get_inventory([host_name], paths=['.hardware.mumpf.'])
+ assert inv[host_name] == {}
finally:
- web.delete_host("test-host")
+ web.delete_host(host_name)