Add test for __func__alias__

This commit is contained in:
Thomas Jackson 2015-02-05 08:29:02 -08:00
parent e2184bd3ee
commit b762c72a2a
2 changed files with 19 additions and 2 deletions

View File

@ -939,7 +939,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
self.missing_modules.append(module_name)
self.missing_modules.append(name)
# If a module has information about why it could not be loaded, record it
return False # TODO Support virtual_errors here
return False
# If this is a proxy minion then MOST modules cannot work. Therefore, require that
# any module that does work with salt-proxy-minion define __proxyenabled__ as a list

View File

@ -140,12 +140,16 @@ class LazyLoaderWhitelistTest(TestCase):
module_template = '''
__load__ = ['test']
__load__ = ['test', 'test_alias']
__func_alias__ = dict(test_alias='working_alias')
from salt.utils.decorators import depends
def test():
return {count}
def test_alias():
return True
def test2():
return True
@ -205,6 +209,19 @@ class LazyLoaderReloadingTest(TestCase):
def module_path(self):
return os.path.join(self.tmp_dir, '{0}.py'.format(self.module_name))
def test_alias(self):
'''
Make sure that you can access alias-d modules
'''
# ensure it doesn't exist
with self.assertRaises(KeyError):
self.loader[self.module_key]
self.update_module()
with self.assertRaises(KeyError):
self.assertTrue(inspect.isfunction(self.loader['{0}.test_alias'.format(self.module_name)]))
self.assertTrue(inspect.isfunction(self.loader['{0}.working_alias'.format(self.module_name)]))
def test_clear(self):
self.assertTrue(inspect.isfunction(self.loader['test.ping']))
self.update_module() # write out out custom module