mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updating tests to reflect changes. Updating to include passed function name in returned docs with message that it is not available.
This commit is contained in:
parent
70f8e89889
commit
016e2e7a34
5 changed files with 31 additions and 4 deletions
|
@ -167,6 +167,7 @@ class BaseCaller(object):
|
|||
if fun not in self.minion.functions:
|
||||
docs = self.minion.functions['sys.doc']('{0}*'.format(fun))
|
||||
if docs:
|
||||
docs[fun] = self.minion.functions.missing_fun_string(fun)
|
||||
ret['out'] = 'nested'
|
||||
ret['return'] = docs
|
||||
return ret
|
||||
|
|
|
@ -442,7 +442,6 @@ class SyncClientMixin(object):
|
|||
_use_fnmatch = True
|
||||
else:
|
||||
target_mod = arg + '.' if not arg.endswith('.') else arg
|
||||
log.debug('target_mod {}'.format(target_mod))
|
||||
if _use_fnmatch:
|
||||
docs = [(fun, self.functions[fun].__doc__)
|
||||
for fun in fnmatch.filter(self.functions, target_mod)]
|
||||
|
|
|
@ -1521,7 +1521,8 @@ class Minion(MinionBase):
|
|||
ret['out'] = 'nested'
|
||||
else:
|
||||
docs = minion_instance.functions['sys.doc']('{0}*'.format(function_name))
|
||||
if all(docs[doc] for doc in docs):
|
||||
if docs:
|
||||
docs[function_name] = minion_instance.functions.missing_fun_string(function_name)
|
||||
ret['return'] = docs
|
||||
else:
|
||||
ret['return'] = minion_instance.functions.missing_fun_string(function_name)
|
||||
|
|
|
@ -9,6 +9,11 @@ import salt.utils.decorators
|
|||
|
||||
|
||||
def _fallbackfunc():
|
||||
'''
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
'''
|
||||
return False, 'fallback'
|
||||
|
||||
|
||||
|
@ -33,11 +38,21 @@ def booldependsTrue():
|
|||
|
||||
@salt.utils.decorators.depends(False)
|
||||
def booldependsFalse():
|
||||
'''
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
'''
|
||||
return True
|
||||
|
||||
|
||||
@salt.utils.decorators.depends('time')
|
||||
def depends():
|
||||
'''
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
'''
|
||||
ret = {'ret': True,
|
||||
'time': time.time()}
|
||||
return ret
|
||||
|
@ -45,6 +60,11 @@ def depends():
|
|||
|
||||
@salt.utils.decorators.depends('time123')
|
||||
def missing_depends():
|
||||
'''
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
'''
|
||||
return True
|
||||
|
||||
|
||||
|
@ -62,6 +82,11 @@ def depends_will_not_fallback():
|
|||
|
||||
@salt.utils.decorators.depends('time123', fallback_function=_fallbackfunc)
|
||||
def missing_depends_will_fallback():
|
||||
'''
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
'''
|
||||
ret = {'ret': True,
|
||||
'time': time.time()}
|
||||
return ret
|
||||
|
|
|
@ -22,8 +22,9 @@ class DecoratorTest(ModuleCase):
|
|||
self.assertTrue(isinstance(ret['time'], float))
|
||||
|
||||
def test_missing_depends(self):
|
||||
self.assertIn(
|
||||
'is not available',
|
||||
self.assertEqual(
|
||||
{'runtests_decorators.missing_depends_will_fallback': '\n CLI Example:\n\n ',
|
||||
'runtests_decorators.missing_depends': "'runtests_decorators.missing_depends' is not available."},
|
||||
self.run_function('runtests_decorators.missing_depends'
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue