mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Merge pull request #7506 from s0undt3ch/develop
Let's try if mocking fixes the intermittent failures of the unit test.
This commit is contained in:
commit
e8c0917962
@ -1,52 +1,67 @@
|
|||||||
|
|
||||||
|
|
||||||
# Import Salt Testing libs
|
# Import Salt Testing libs
|
||||||
from salttesting import TestCase
|
from salttesting import skipIf, TestCase
|
||||||
from salttesting.helpers import ensure_in_syspath
|
from salttesting.helpers import ensure_in_syspath
|
||||||
|
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch
|
||||||
|
|
||||||
ensure_in_syspath('../../')
|
ensure_in_syspath('../../')
|
||||||
|
|
||||||
# Import Salt libs
|
# Import Salt libs
|
||||||
from salt.modules import config
|
from salt.modules import config
|
||||||
|
|
||||||
config.__opts__ = {
|
|
||||||
"test.option.all": "value of test.option.all in __opts__"
|
config.__opts__ = config.__pillar__ = {}
|
||||||
|
|
||||||
|
__opts__ = {
|
||||||
|
'test.option.all': 'value of test.option.all in __opts__'
|
||||||
}
|
}
|
||||||
config.__pillar__ = {
|
__pillar__ = {
|
||||||
"test.option.all": "value of test.option.all in __pillar__",
|
'test.option.all': 'value of test.option.all in __pillar__',
|
||||||
"master": {
|
'master': {
|
||||||
"test.option.all": "value of test.option.all in maste"
|
'test.option.all': 'value of test.option.all in master'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.DEFAULTS["test.option.all"] = "value of test.option.all in DEFAUTS"
|
DEFAULTS = {
|
||||||
config.DEFAULTS["test.option"] = "value of test.option in DEFAUTS"
|
'test.option.all': 'value of test.option.all in DEFAULTS',
|
||||||
|
'test.option': 'value of test.option in DEFAULTS'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||||
class TestModulesConfig(TestCase):
|
class TestModulesConfig(TestCase):
|
||||||
def test_defaults_only_name(self,):
|
def test_defaults_only_name(self):
|
||||||
opt_name = "test.option"
|
with patch.dict(config.DEFAULTS, DEFAULTS):
|
||||||
opt = config.option(opt_name)
|
opt_name = 'test.option'
|
||||||
self.assertEqual(opt, config.DEFAULTS[opt_name])
|
opt = config.option(opt_name)
|
||||||
|
self.assertEqual(opt, config.DEFAULTS[opt_name])
|
||||||
|
|
||||||
def test_omits(self,):
|
def test_omits(self):
|
||||||
opt_name = "test.option.all"
|
with patch.dict(config.DEFAULTS, DEFAULTS):
|
||||||
opt = config.option(opt_name, omit_opts=False,
|
with patch.dict(config.__pillar__, __pillar__):
|
||||||
omit_master=True,
|
with patch.dict(config.__opts__, __opts__):
|
||||||
omit_pillar=True)
|
opt_name = 'test.option.all'
|
||||||
|
opt = config.option(opt_name,
|
||||||
|
omit_opts=False,
|
||||||
|
omit_master=True,
|
||||||
|
omit_pillar=True)
|
||||||
|
|
||||||
self.assertEqual(opt, config.__opts__[opt_name])
|
self.assertEqual(opt, config.__opts__[opt_name])
|
||||||
|
|
||||||
opt = config.option(opt_name, omit_opts=True,
|
opt = config.option(opt_name,
|
||||||
omit_master=True,
|
omit_opts=True,
|
||||||
omit_pillar=False)
|
omit_master=True,
|
||||||
|
omit_pillar=False)
|
||||||
|
|
||||||
self.assertEqual(opt, config.__pillar__[opt_name])
|
self.assertEqual(opt, config.__pillar__[opt_name])
|
||||||
opt = config.option(opt_name, omit_opts=True,
|
opt = config.option(opt_name,
|
||||||
omit_master=False,
|
omit_opts=True,
|
||||||
omit_pillar=True)
|
omit_master=False,
|
||||||
|
omit_pillar=True)
|
||||||
|
|
||||||
self.assertEqual(opt, config.__pillar__['master'][opt_name])
|
self.assertEqual(
|
||||||
|
opt, config.__pillar__['master'][opt_name])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user