2015-04-09 12:02:17 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2015-04-21 18:25:31 +00:00
|
|
|
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Python Libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
# Import Salt Testing Libs
|
2017-02-19 15:35:30 +00:00
|
|
|
from tests.support.mixins import LoaderModuleMockMixin
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.unit import TestCase, skipIf
|
|
|
|
from tests.support.mock import (
|
2015-04-09 12:02:17 +00:00
|
|
|
patch,
|
|
|
|
NO_MOCK,
|
|
|
|
NO_MOCK_REASON
|
|
|
|
)
|
|
|
|
|
|
|
|
# Import Salt Libs
|
2017-03-21 17:15:36 +00:00
|
|
|
import salt.modules.sysmod as sysmod
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
|
|
|
|
class MockDocstringable(object):
|
|
|
|
def __init__(self, docstr):
|
|
|
|
self.__doc__ = docstr
|
|
|
|
|
|
|
|
def set_module_docstring(self, docstr):
|
|
|
|
self.__globals__ = {'__doc__': docstr}
|
|
|
|
|
|
|
|
|
2015-04-09 12:02:17 +00:00
|
|
|
class Mockstate(object):
|
|
|
|
"""
|
|
|
|
Mock of State
|
|
|
|
"""
|
|
|
|
class State(object):
|
|
|
|
"""
|
2016-08-09 20:03:24 +00:00
|
|
|
Mock state functions
|
2015-04-09 12:02:17 +00:00
|
|
|
"""
|
2016-08-04 09:18:22 +00:00
|
|
|
states = {}
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def __init__(self, opts):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Mockrunner(object):
|
|
|
|
"""
|
|
|
|
Mock of runner
|
|
|
|
"""
|
|
|
|
class Runner(object):
|
|
|
|
"""
|
2016-08-09 20:03:24 +00:00
|
|
|
Mock runner functions
|
2015-04-09 12:02:17 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, opts):
|
|
|
|
pass
|
|
|
|
|
2017-02-19 15:35:30 +00:00
|
|
|
@property
|
|
|
|
def functions(self):
|
|
|
|
return sysmod.__salt__
|
|
|
|
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
class Mockloader(object):
|
|
|
|
"""
|
|
|
|
Mock of loader
|
|
|
|
"""
|
2016-08-08 15:27:47 +00:00
|
|
|
functions = [] # ? does not have any effect on existing tests
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2016-08-09 20:03:24 +00:00
|
|
|
pass
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def returners(self, opts, lst):
|
|
|
|
"""
|
2016-08-09 20:03:24 +00:00
|
|
|
Mock returner functions
|
2015-04-09 12:02:17 +00:00
|
|
|
"""
|
2016-08-08 11:59:15 +00:00
|
|
|
return sysmod.__salt__
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def render(self, opts, lst):
|
|
|
|
"""
|
2016-08-09 20:03:24 +00:00
|
|
|
Mock renderers
|
2015-04-09 12:02:17 +00:00
|
|
|
"""
|
2016-08-09 20:03:24 +00:00
|
|
|
return sysmod.__salt__ # renderers do not have '.'s; but whatever. This is for convenience
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2017-02-19 15:35:30 +00:00
|
|
|
class SysmodTestCase(TestCase, LoaderModuleMockMixin):
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
|
|
|
Test cases for salt.modules.sysmod
|
|
|
|
'''
|
2017-03-22 12:12:36 +00:00
|
|
|
def setup_loader_modules(self):
|
|
|
|
return {sysmod: {'__salt__': self.salt_dunder}}
|
2017-02-19 15:35:30 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
cls._modules = set()
|
|
|
|
cls._functions = [
|
|
|
|
'exist.exist',
|
|
|
|
|
|
|
|
'sys.doc', 'sys.list_functions', 'sys.list_modules',
|
|
|
|
'sysctl.get', 'sysctl.show',
|
|
|
|
'system.halt', 'system.reboot',
|
|
|
|
|
|
|
|
'udev.name', 'udev.path',
|
|
|
|
'user.add', 'user.info', 'user.rename',
|
|
|
|
]
|
|
|
|
cls._docstrings = {}
|
|
|
|
cls._statedocstrings = {}
|
|
|
|
|
|
|
|
cls.salt_dunder = {}
|
|
|
|
|
|
|
|
for func in cls._functions:
|
|
|
|
docstring = 'docstring for {0}'.format(func)
|
|
|
|
|
|
|
|
cls.salt_dunder[func] = MockDocstringable(docstring)
|
|
|
|
cls._docstrings[func] = docstring
|
|
|
|
|
|
|
|
module = func.split('.')[0]
|
|
|
|
cls._statedocstrings[func] = docstring
|
|
|
|
cls._statedocstrings[module] = 'docstring for {0}'.format(module)
|
|
|
|
|
|
|
|
cls._modules.add(func.split('.')[0])
|
|
|
|
|
|
|
|
docstring = 'docstring for {0}'.format(func)
|
|
|
|
mock = MockDocstringable(docstring)
|
|
|
|
mock.set_module_docstring('docstring for {0}'.format(func.split('.')[0]))
|
|
|
|
Mockstate.State.states[func] = mock
|
|
|
|
|
|
|
|
cls._modules = sorted(list(cls._modules))
|
|
|
|
|
|
|
|
cls.state_patcher = patch('salt.state', Mockstate())
|
|
|
|
cls.state_patcher.start()
|
|
|
|
cls.runner_patcher = patch('salt.runner', Mockrunner())
|
|
|
|
cls.runner_patcher.start()
|
|
|
|
cls.loader_patcher = patch('salt.loader', Mockloader())
|
|
|
|
cls.loader_patcher.start()
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'doc' function tests: 2
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2017-02-19 15:35:30 +00:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
cls.runner_patcher.stop()
|
|
|
|
cls.state_patcher.stop()
|
|
|
|
cls.loader_patcher.stop()
|
|
|
|
for attrname in ('_modules', '_functions', '_docstrings', '_statedocstrings', 'salt_dunder',
|
|
|
|
'runner_patcher', 'state_patcher', 'loader_patcher'):
|
|
|
|
try:
|
|
|
|
delattr(cls, attrname)
|
|
|
|
except AttributeError:
|
|
|
|
continue
|
|
|
|
|
2015-04-09 12:02:17 +00:00
|
|
|
def test_doc(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it returns the docstrings for all modules.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertDictEqual(sysmod.doc(), self._docstrings)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertDictEqual(sysmod.doc('sys.doc'), {'sys.doc': 'docstring for sys.doc'})
|
2016-08-08 11:59:15 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'state_doc' function tests: 2
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_state_doc(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it returns the docstrings for all states.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertDictEqual(sysmod.state_doc(), self._statedocstrings)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertDictEqual(sysmod.state_doc('sys.doc'), {'sys': 'docstring for sys', 'sys.doc': 'docstring for sys.doc'})
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'runner_doc' function tests: 2
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_runner_doc(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it returns the docstrings for all runners.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertDictEqual(sysmod.runner_doc(), self._docstrings)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertDictEqual(sysmod.runner_doc('sys.doc'), {'sys.doc': 'docstring for sys.doc'})
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'returner_doc' function tests: 2
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_returner_doc(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it returns the docstrings for all returners.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertDictEqual(sysmod.returner_doc(), self._docstrings)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertDictEqual(sysmod.returner_doc('sys.doc'), {'sys.doc': 'docstring for sys.doc'})
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'renderer_doc' function tests: 2
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_renderer_doc(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it returns the docstrings for all renderers.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertDictEqual(sysmod.renderer_doc(), self._docstrings)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertDictEqual(sysmod.renderer_doc('sys.doc'), {'sys.doc': 'docstring for sys.doc'})
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_functions' function tests: 7
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_functions(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the functions for all modules.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions(), self._functions)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-04 04:38:45 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions('nonexist'), [])
|
2016-08-02 04:24:22 +00:00
|
|
|
|
2016-08-06 11:22:14 +00:00
|
|
|
# list all functions in/given a specific module
|
2016-08-02 04:06:46 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions('sys'), ['sys.doc', 'sys.list_functions', 'sys.list_modules'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-03 07:14:11 +00:00
|
|
|
# globs can be used for both module names and function names:
|
|
|
|
self.assertListEqual(sysmod.list_functions('sys*'), ['sys.doc', 'sys.list_functions', 'sys.list_modules', 'sysctl.get', 'sysctl.show', 'system.halt', 'system.reboot'])
|
2016-08-02 04:24:22 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions('sys.list*'), ['sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
2016-08-06 11:22:14 +00:00
|
|
|
# "list", or check for a specific function:
|
2016-08-03 07:14:11 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions('sys.list'), [])
|
2016-08-06 11:22:14 +00:00
|
|
|
self.assertListEqual(sysmod.list_functions('exist.exist'), ['exist.exist'])
|
2016-08-02 04:24:22 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_modules' function tests: 4
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_modules(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the modules loaded on the minion
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_modules(), self._modules)
|
2016-07-30 20:41:49 +00:00
|
|
|
|
2016-08-02 04:24:22 +00:00
|
|
|
self.assertListEqual(sysmod.list_modules('nonexist'), [])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-07-30 20:41:49 +00:00
|
|
|
self.assertListEqual(sysmod.list_modules('user'), ['user'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-02 04:24:22 +00:00
|
|
|
self.assertListEqual(sysmod.list_modules('s*'), ['sys', 'sysctl', 'system'])
|
|
|
|
|
2015-04-09 12:02:17 +00:00
|
|
|
# 'reload_modules' function tests: 1
|
|
|
|
|
|
|
|
def test_reload_modules(self):
|
|
|
|
'''
|
|
|
|
Test if it tell the minion to reload the execution modules
|
|
|
|
'''
|
|
|
|
self.assertTrue(sysmod.reload_modules())
|
|
|
|
|
|
|
|
# 'argspec' function tests: 1
|
|
|
|
|
|
|
|
def test_argspec(self):
|
|
|
|
'''
|
|
|
|
Test if it return the argument specification
|
|
|
|
of functions in Salt execution modules.
|
|
|
|
'''
|
|
|
|
self.assertDictEqual(sysmod.argspec(), {})
|
|
|
|
|
|
|
|
# 'state_argspec' function tests: 1
|
|
|
|
|
|
|
|
def test_state_argspec(self):
|
|
|
|
'''
|
|
|
|
Test if it return the argument specification
|
|
|
|
of functions in Salt state modules.
|
|
|
|
'''
|
|
|
|
self.assertDictEqual(sysmod.state_argspec(), {})
|
|
|
|
|
|
|
|
# 'returner_argspec' function tests: 1
|
|
|
|
|
|
|
|
def test_returner_argspec(self):
|
|
|
|
'''
|
|
|
|
Test if it return the argument specification
|
|
|
|
of functions in Salt returner modules.
|
|
|
|
'''
|
|
|
|
self.assertDictEqual(sysmod.returner_argspec(), {})
|
|
|
|
|
|
|
|
# 'runner_argspec' function tests: 1
|
|
|
|
|
|
|
|
def test_runner_argspec(self):
|
|
|
|
'''
|
|
|
|
Test if it return the argument specification of functions in Salt runner
|
|
|
|
modules.
|
|
|
|
'''
|
|
|
|
self.assertDictEqual(sysmod.runner_argspec(), {})
|
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_state_functions' function tests: 7
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_state_functions(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the functions for all state modules.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_state_functions(), self._functions)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-06 11:22:14 +00:00
|
|
|
self.assertListEqual(sysmod.list_state_functions('nonexist'), [])
|
|
|
|
|
|
|
|
# list all functions in/given a specific module
|
|
|
|
self.assertListEqual(sysmod.list_state_functions('sys'), ['sys.doc', 'sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
|
|
|
# globs can be used for both module names and function names:
|
|
|
|
self.assertListEqual(sysmod.list_state_functions('sys*'), ['sys.doc', 'sys.list_functions', 'sys.list_modules', 'sysctl.get', 'sysctl.show', 'system.halt', 'system.reboot'])
|
|
|
|
self.assertListEqual(sysmod.list_state_functions('sys.list*'), ['sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
|
|
|
# "list", or check for a specific function:
|
|
|
|
self.assertListEqual(sysmod.list_state_functions('sys.list'), [])
|
|
|
|
self.assertListEqual(sysmod.list_state_functions('exist.exist'), ['exist.exist'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_state_modules' function tests: 4
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_state_modules(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the modules loaded on the minion.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_state_modules(), self._modules)
|
2016-08-04 09:18:22 +00:00
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_state_modules('nonexist'), [])
|
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_state_modules('user'), ['user'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-04 09:18:22 +00:00
|
|
|
self.assertListEqual(sysmod.list_state_modules('s*'), ['sys', 'sysctl', 'system'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-10 00:30:30 +00:00
|
|
|
# 'list_runners' function tests: 4
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_runners(self):
|
|
|
|
'''
|
|
|
|
Test if it list the runners loaded on the minion.
|
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_runners(), self._modules)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-10 00:30:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_runners('nonexist'), [])
|
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_runners('user'), ['user'])
|
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_runners('s*'), ['sys', 'sysctl', 'system'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_runner_functions' function tests: 7
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_runner_functions(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the functions for all runner modules.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_runner_functions(), self._functions)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-06 11:50:14 +00:00
|
|
|
self.assertListEqual(sysmod.list_runner_functions('nonexist'), [])
|
|
|
|
|
|
|
|
# list all functions in/given a specific module
|
|
|
|
self.assertListEqual(sysmod.list_runner_functions('sys'), ['sys.doc', 'sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
|
|
|
# globs can be used for both module names and function names:
|
|
|
|
self.assertListEqual(sysmod.list_runner_functions('sys*'), ['sys.doc', 'sys.list_functions', 'sys.list_modules', 'sysctl.get', 'sysctl.show', 'system.halt', 'system.reboot'])
|
|
|
|
self.assertListEqual(sysmod.list_runner_functions('sys.list*'), ['sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
|
|
|
# "list", or check for a specific function:
|
|
|
|
self.assertListEqual(sysmod.list_runner_functions('sys.list'), [])
|
|
|
|
self.assertListEqual(sysmod.list_runner_functions('exist.exist'), ['exist.exist'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-10 00:43:47 +00:00
|
|
|
# 'list_returners' function tests: 4
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_returners(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the returners loaded on the minion
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_returners(), self._modules)
|
2016-08-09 20:03:24 +00:00
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_returners('nonexist'), [])
|
|
|
|
|
2016-08-10 00:43:47 +00:00
|
|
|
self.assertListEqual(sysmod.list_returners('user'), ['user'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
self.assertListEqual(sysmod.list_returners('s*'), ['sys', 'sysctl', 'system'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-09 20:03:24 +00:00
|
|
|
# 'list_returner_functions' function tests: 7
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_returner_functions(self):
|
|
|
|
'''
|
2016-08-09 20:03:24 +00:00
|
|
|
Test if it lists the functions for all returner modules.
|
2015-04-09 12:02:17 +00:00
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_returner_functions(), self._functions)
|
2016-08-08 11:59:15 +00:00
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('nonexist'), [])
|
|
|
|
|
|
|
|
# list all functions in/given a specific module
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('sys'), ['sys.doc', 'sys.list_functions', 'sys.list_modules'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-08 11:59:15 +00:00
|
|
|
# globs can be used for both module names and function names:
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('sys*'), ['sys.doc', 'sys.list_functions', 'sys.list_modules', 'sysctl.get', 'sysctl.show', 'system.halt', 'system.reboot'])
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('sys.list*'), ['sys.list_functions', 'sys.list_modules'])
|
|
|
|
|
|
|
|
# "list", or check for a specific function:
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('sys.list'), [])
|
|
|
|
self.assertListEqual(sysmod.list_returner_functions('exist.exist'), ['exist.exist'])
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-10 01:13:08 +00:00
|
|
|
# 'list_renderers' function tests: 4
|
2015-04-09 12:02:17 +00:00
|
|
|
|
|
|
|
def test_list_renderers(self):
|
|
|
|
'''
|
|
|
|
Test if it list the renderers loaded on the minion.
|
|
|
|
'''
|
2017-02-19 15:35:30 +00:00
|
|
|
self.assertListEqual(sysmod.list_renderers(), self._functions)
|
2015-04-09 12:02:17 +00:00
|
|
|
|
2016-08-10 01:13:08 +00:00
|
|
|
self.assertListEqual(sysmod.list_renderers('nonexist'), [])
|
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_renderers('user.info'), ['user.info'])
|
|
|
|
|
|
|
|
self.assertListEqual(sysmod.list_renderers('syst*'), ['system.halt', 'system.reboot'])
|