Skip to content

Commit

Permalink
add unittest for grains_blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
zr committed Sep 22, 2018
1 parent d4ffa8f commit 4286e1d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/unit/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,31 @@ def test_whitelist(self):
self.assertNotIn('grains.get', self.loader)


class LazyLoaderGrainsBlacklistTest(TestCase):
'''
Test the loader of grains with a blacklist
'''
def setUp(self):
self.opts = salt.config.minion_config(None)

def tearDown(self):
del self.opts

def test_whitelist(self):
opts = copy.deepcopy(self.opts)
opts['grains_blacklist'] = [
'master',
'os*',
'ipv[46]'
]

grains = salt.loader.grains(opts)
self.assertNotIn('master', grains)
self.assertNotIn('os', set([g[:2] for g in list(grains)]))
self.assertNotIn('ipv4', grains)
self.assertNotIn('ipv6', grains)


class LazyLoaderSingleItem(TestCase):
'''
Test loading a single item via the _load() function
Expand Down

0 comments on commit 4286e1d

Please sign in to comment.