From b762c72a2a3666946343f55e4e0604594daa259b Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Thu, 5 Feb 2015 08:29:02 -0800 Subject: [PATCH] Add test for __func__alias__ --- salt/loader.py | 2 +- tests/unit/loader.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 0e9b637e44..299cc46e5c 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -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 diff --git a/tests/unit/loader.py b/tests/unit/loader.py index c4695e45f2..7901b02c0d 100644 --- a/tests/unit/loader.py +++ b/tests/unit/loader.py @@ -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