Module: check_mk
Branch: master
Commit: 1fb43015953d736273abdcfa5602e06bc0d21a5d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1fb43015953d73…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Feb 20 08:24:18 2018 +0100
Add first tests for management board attributes
Change-Id: I92c8c5e3512058fb3cf77e33c63e7b8f7a44fe04
---
tests/cmk_base/test_mgmt_board.py | 66 +++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/tests/cmk_base/test_mgmt_board.py b/tests/cmk_base/test_mgmt_board.py
new file mode 100644
index 0000000..06fa2a3
--- /dev/null
+++ b/tests/cmk_base/test_mgmt_board.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+
+import pytest
+from testlib import web
+
+import cmk_base.config as config
+
+(a)pytest.fixture(scope="module")
+def test_cfg(web, site):
+ print "Applying default config"
+ web.add_host("mgmt-host1", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": "snmp",
+ "management_snmp_community": "HOST",
+ })
+ web.add_host("mgmt-host2", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": "snmp",
+ "management_address": "127.0.0.2",
+ })
+ web.add_host("mgmt-host3", attributes={
+ "ipaddress": "127.0.0.1",
+ "management_protocol": None,
+ "management_address": "127.0.0.1",
+ "management_snmp_community": "HOST",
+ })
+
+ web.activate_changes()
+
+ import cmk.debug
+ cmk.debug.enable()
+
+ import cmk_base.checks as checks
+ checks.load()
+ config.load()
+
+ yield None
+
+ #
+ # Cleanup code
+ #
+ print "Cleaning up test config"
+
+ cmk.debug.disable()
+
+ web.delete_host("mgmt-host1")
+ web.delete_host("mgmt-host2")
+ web.delete_host("mgmt-host3")
+ web.activate_changes()
+
+
+def test_management_board_configc(test_cfg):
+ assert config.has_management_board("mgmt-host1")
+ assert config.management_address_of("mgmt-host1") == "127.0.0.1"
+ assert config.management_protocol_of("mgmt-host1") == "snmp"
+ assert config.management_credentials_of("mgmt-host1") == "HOST"
+
+ assert config.has_management_board("mgmt-host2")
+ assert config.management_address_of("mgmt-host2") == "127.0.0.2"
+ assert config.management_protocol_of("mgmt-host2") == "snmp"
+ assert config.management_credentials_of("mgmt-host2") ==
"public"
+
+ assert config.has_management_board("mgmt-host3") == False
+ assert config.management_address_of("mgmt-host3") == "127.0.0.1"
+ assert config.management_protocol_of("mgmt-host3") == None
+ assert config.management_credentials_of("mgmt-host3") == "HOST"