mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Lint 34644 (#34651)
* Better error handling for __virtual__ in dockerng module * Modify lodaer global test to use populated dunders This prevents a number of errors in the error log and makes for a more robust test IMHO * Lint #34644
This commit is contained in:
parent
50360263c5
commit
bc63f25a6f
2 changed files with 26 additions and 12 deletions
|
@ -526,8 +526,12 @@ def __virtual__():
|
|||
Only load if docker libs are present
|
||||
'''
|
||||
if HAS_DOCKER_PY:
|
||||
docker_py_versioninfo = _get_docker_py_versioninfo()
|
||||
|
||||
try:
|
||||
docker_py_versioninfo = _get_docker_py_versioninfo()
|
||||
except Exception:
|
||||
# May fail if we try to connect to a docker daemon but can't
|
||||
return (False, 'Docker module found, but no version could be'
|
||||
' extracted')
|
||||
# Don't let a failure to interpret the version keep this module from
|
||||
# loading. Log a warning (log happens in _get_docker_py_versioninfo()).
|
||||
if docker_py_versioninfo is None:
|
||||
|
@ -536,7 +540,7 @@ def __virtual__():
|
|||
if docker_py_versioninfo >= MIN_DOCKER_PY:
|
||||
try:
|
||||
docker_versioninfo = version().get('VersionInfo')
|
||||
except CommandExecutionError:
|
||||
except Exception:
|
||||
docker_versioninfo = None
|
||||
|
||||
if docker_versioninfo is None or docker_versioninfo >= MIN_DOCKER:
|
||||
|
|
|
@ -19,6 +19,7 @@ import integration
|
|||
import salt.loader
|
||||
import inspect
|
||||
import yaml
|
||||
import copy
|
||||
|
||||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
|
@ -33,6 +34,15 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
|
||||
This is intended as a shorter term way of testing these so we don't break the loader
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
# Poor man's classSetUp (not supported in 2.6)
|
||||
if not hasattr(self, 'minion_mods'):
|
||||
self.opts = dict(copy.deepcopy(self.master_opts))
|
||||
self.opts['grains'] = salt.loader.grains(self.opts)
|
||||
self.utils = salt.loader.utils(self.opts)
|
||||
self.minion_mods = salt.loader.minion_mods(self.opts, utils=self.utils)
|
||||
|
||||
def _verify_globals(self, mod_dict):
|
||||
'''
|
||||
Verify that the globals listed in the doc string (from the test) are in these modules
|
||||
|
@ -64,7 +74,7 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __salt__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.auth(self.master_opts))
|
||||
self._verify_globals(salt.loader.auth(self.opts))
|
||||
|
||||
def test_runners(self):
|
||||
'''
|
||||
|
@ -75,7 +85,7 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __grains__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.runner(self.master_opts))
|
||||
self._verify_globals(salt.loader.runner(self.opts))
|
||||
|
||||
def test_returners(self):
|
||||
'''
|
||||
|
@ -86,7 +96,7 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __grains__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.returners(self.master_opts, {}))
|
||||
self._verify_globals(salt.loader.returners(self.opts, {}))
|
||||
|
||||
def test_pillars(self):
|
||||
'''
|
||||
|
@ -97,13 +107,13 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __grains__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.pillars(self.master_opts, {}))
|
||||
self._verify_globals(salt.loader.pillars(self.opts, {}))
|
||||
|
||||
def test_tops(self):
|
||||
'''
|
||||
Test that tops have: []
|
||||
'''
|
||||
self._verify_globals(salt.loader.tops(self.master_opts))
|
||||
self._verify_globals(salt.loader.tops(self.opts))
|
||||
|
||||
def test_outputters(self):
|
||||
'''
|
||||
|
@ -113,13 +123,13 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __grains__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.outputters(self.master_opts))
|
||||
self._verify_globals(salt.loader.outputters(self.opts))
|
||||
|
||||
def test_serializers(self):
|
||||
'''
|
||||
Test that serializers have: []
|
||||
'''
|
||||
self._verify_globals(salt.loader.serializers(self.master_opts))
|
||||
self._verify_globals(salt.loader.serializers(self.opts))
|
||||
|
||||
def test_states(self):
|
||||
'''
|
||||
|
@ -130,7 +140,7 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __grains__
|
||||
- __context__
|
||||
'''
|
||||
self._verify_globals(salt.loader.states(self.master_opts, {}, {}))
|
||||
self._verify_globals(salt.loader.states(self.opts, self.minion_mods, {}))
|
||||
|
||||
def test_renderers(self):
|
||||
'''
|
||||
|
@ -141,7 +151,7 @@ class LoaderGlobalsTest(integration.ModuleCase):
|
|||
- __opts__ # Minion configuration options
|
||||
- __context__ # Context dict shared amongst all modules of the same type
|
||||
'''
|
||||
self._verify_globals(salt.loader.render(self.master_opts, {}))
|
||||
self._verify_globals(salt.loader.render(self.opts, {}))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue