Module: check_mk
Branch: master
Commit: eca07079a3dbc8c1fcb5aa482d3b1bdf21e83aca
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eca07079a3dbc8…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Jan 15 15:17:54 2019 +0100
Improved web API unit test.
Do not test internal implementation details, test the names of the exposed
actions instead.
Change-Id: I976de3bb857f59532ad46e5b9286c5f793423f84
---
tests/unit/cmk/gui/test_webapi_unit.py | 68 +++++++++++++++++++++++++---------
1 file changed, 50 insertions(+), 18 deletions(-)
diff --git a/tests/unit/cmk/gui/test_webapi_unit.py
b/tests/unit/cmk/gui/test_webapi_unit.py
index 8d9cc70..ea1dad0 100644
--- a/tests/unit/cmk/gui/test_webapi_unit.py
+++ b/tests/unit/cmk/gui/test_webapi_unit.py
@@ -1,21 +1,53 @@
+from cmk.gui.plugins.webapi.utils import api_call_collection_registry
-import cmk.gui.webapi
-
-import cmk.gui.plugins.webapi.utils as webapi_utils
def test_registered_api_call_collections():
- registered_plugins = sorted(webapi_utils.api_call_collection_registry.keys())
- assert registered_plugins == [
- 'APICallBIAggregationState',
- 'APICallBakery',
- 'APICallFolders',
- 'APICallGraph',
- 'APICallGroups',
- 'APICallHosts',
- 'APICallHosttags',
- 'APICallOther',
- 'APICallRules',
- 'APICallSLA',
- 'APICallSites',
- 'APICallUsers',
- ]
+ registered_api_actions = (action \
+ for cls in api_call_collection_registry.values()
+ for action in cls().get_api_calls().iterkeys())
+ assert sorted(registered_api_actions) == sorted([
+ 'activate_changes',
+ 'add_contactgroup',
+ 'add_folder',
+ 'add_host',
+ 'add_hostgroup',
+ 'add_hosts',
+ 'add_servicegroup',
+ 'add_users',
+ 'delete_contactgroup',
+ 'delete_folder',
+ 'delete_host',
+ 'delete_hostgroup',
+ 'delete_hosts',
+ 'delete_servicegroup',
+ 'delete_site',
+ 'delete_users',
+ 'discover_services',
+ 'edit_contactgroup',
+ 'edit_folder',
+ 'edit_host',
+ 'edit_hostgroup',
+ 'edit_hosts',
+ 'edit_servicegroup',
+ 'edit_users',
+ 'get_all_contactgroups',
+ 'get_all_folders',
+ 'get_all_hostgroups',
+ 'get_all_hosts',
+ 'get_all_servicegroups',
+ 'get_all_sites',
+ 'get_all_users',
+ 'get_bi_aggregations',
+ 'get_folder',
+ 'get_host',
+ 'get_hosttags',
+ 'get_ruleset',
+ 'get_rulesets_info',
+ 'get_site',
+ 'login_site',
+ 'logout_site',
+ 'set_all_sites',
+ 'set_hosttags',
+ 'set_ruleset',
+ 'set_site',
+ ])