mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #33511 from rallytime/fix-33500
Allow exact arg matches to work in sys.list_modules func
This commit is contained in:
commit
378bc96234
@ -401,6 +401,8 @@ def list_modules(*args):
|
||||
return sorted(modules)
|
||||
|
||||
for module in args:
|
||||
if '*' not in module:
|
||||
module += '*'
|
||||
for func in fnmatch.filter(__salt__, module):
|
||||
comps = func.split('.')
|
||||
if len(comps) < 2:
|
||||
|
@ -45,12 +45,32 @@ class SysModuleTest(integration.ModuleCase):
|
||||
|
||||
def test_list_modules(self):
|
||||
'''
|
||||
sys.list_moduels
|
||||
sys.list_modules
|
||||
'''
|
||||
mods = self.run_function('sys.list_modules')
|
||||
self.assertTrue('hosts' in mods)
|
||||
self.assertTrue('pkg' in mods)
|
||||
|
||||
def test_list_modules_with_arg(self):
|
||||
'''
|
||||
sys.list_modules u*
|
||||
|
||||
Tests getting the list of modules looking for the "user" module
|
||||
'''
|
||||
mods = self.run_function('sys.list_modules', 'u*')
|
||||
self.assertIn('user', mods)
|
||||
|
||||
def test_list_modules_with_arg_exact_match(self):
|
||||
'''
|
||||
sys.list_modules user
|
||||
|
||||
Tests getting the list of modules looking for the "user" module with
|
||||
an exact match of 'user' being passed at the CLI instead of something
|
||||
with '*'.
|
||||
'''
|
||||
mods = self.run_function('sys.list_modules', 'user')
|
||||
self.assertIn('user', mods)
|
||||
|
||||
def test_valid_docs(self):
|
||||
'''
|
||||
Make sure no functions are exposed that don't have valid docstrings
|
||||
|
Loading…
Reference in New Issue
Block a user