Module: check_mk
Branch: master
Commit: a604ad9f22efce8695f40631dc6579f02731bb51
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a604ad9f22efce…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Wed Nov 8 17:05:01 2017 +0100
df: Discovery test for the behaviour of the include volume name rule
Change-Id: I4cf914a938903be0c101ac2f31352348f15cefa1
---
tests/checks/test_df.py | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/tests/checks/test_df.py b/tests/checks/test_df.py
index 10386e5..13bf982 100644
--- a/tests/checks/test_df.py
+++ b/tests/checks/test_df.py
@@ -1,11 +1,41 @@
import pytest
+import pprint
+import sys
pytestmark = pytest.mark.check
-(a)pytest.mark.parametrize("info,result"sult", [
- ([], [])
+(a)pytest.mark.parametrize("info,result,include_volume_name"name", [
+ ([], [], False),
+ ([[u'/dev/sda4',
+ u'ext4',
+ u'143786696',
+ u'101645524',
+ u'34814148',
+ u'75%',
+ u'/'],
+ [u'[df_inodes_start]'],
+ [u'/dev/sda4', u'ext4', u'9142272', u'1654272',
u'7488000', u'19%', u'/'],
+ [u'[df_inodes_end]']], [(u'/', {})], False),
+ ([[u'/dev/sda4',
+ u'ext4',
+ u'143786696',
+ u'101645524',
+ u'34814148',
+ u'75%',
+ u'/'],
+ [u'[df_inodes_start]'],
+ [u'/dev/sda4', u'ext4', u'9142272', u'1654272',
u'7488000', u'19%', u'/'],
+ [u'[df_inodes_end]']], [(u'/dev/sda4 /', {})], True),
])
-def test_df_discovery_with_parse(check_manager, info, result):
+def test_df_discovery_with_parse(check_manager, monkeypatch, info, result,
include_volume_name):
+ import cmk_base.checks
+
+# NOTE: This is the result of trying to mock the the ruleset variable itself instead of
the
+# host_extra_conf_merged function. It did not work. Maybe we can get it to work
at a later stage.
+# import cmk_base.rulesets
+# monkeypatch.setitem(cmk_base.checks._check_contexts["df"],
"inventory_df_rules",
+# [({"include_volume_name": include_volume_name}, [],
cmk_base.rulesets.ALL_HOSTS, {})])
+
check = check_manager.get_check("df")
+ monkeypatch.setitem(cmk_base.checks._check_contexts["df"],
"host_extra_conf_merged", lambda _, __: {"include_volume_name":
include_volume_name})
assert check.run_discovery(check.run_parse(info)) == result
-