Skip to content

Commit

Permalink
Modify lodaer global test to use populated dunders
Browse files Browse the repository at this point in the history
This prevents a number of errors in the error log and makes for a
more robust test IMHO
  • Loading branch information
Mike Place committed Jul 13, 2016
1 parent f9c3d8d commit f45dbe8
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions tests/integration/loader/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import salt.loader
import inspect
import yaml
import copy

# Import 3rd-party libs
import salt.ext.six as six



class LoaderGlobalsTest(integration.ModuleCase):
'''
Test all of the globals that the loader is responsible for adding to modules
Expand All @@ -33,6 +35,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
Expand Down Expand Up @@ -64,7 +75,7 @@ def test_auth(self):
- __salt__
- __context__
'''
self._verify_globals(salt.loader.auth(self.master_opts))
self._verify_globals(salt.loader.auth(self.opts))

def test_runners(self):
'''
Expand All @@ -75,7 +86,7 @@ def test_runners(self):
- __grains__
- __context__
'''
self._verify_globals(salt.loader.runner(self.master_opts))
self._verify_globals(salt.loader.runner(self.opts))

def test_returners(self):
'''
Expand All @@ -86,7 +97,7 @@ def test_returners(self):
- __grains__
- __context__
'''
self._verify_globals(salt.loader.returners(self.master_opts, {}))
self._verify_globals(salt.loader.returners(self.opts, {}))

def test_pillars(self):
'''
Expand All @@ -97,13 +108,13 @@ def test_pillars(self):
- __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):
'''
Expand All @@ -113,13 +124,13 @@ def test_outputters(self):
- __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):
'''
Expand All @@ -130,7 +141,7 @@ def test_states(self):
- __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):
'''
Expand All @@ -141,7 +152,7 @@ def test_renderers(self):
- __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__':
Expand Down

0 comments on commit f45dbe8

Please sign in to comment.