Merge pull request #33511 from rallytime/fix-33500

Allow exact arg matches to work in sys.list_modules func
This commit is contained in:
Mike Place 2016-05-26 07:28:46 -07:00
commit 378bc96234
2 changed files with 23 additions and 1 deletions

View File

@ -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:

View File

@ -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