mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #3334 from s0undt3ch/develop
Fix `tests.unit.pydsl_test` and `tests.unit.stateconf_test`.
This commit is contained in:
commit
d9b1997c30
@ -13,10 +13,7 @@ from salt.renderers.yaml import HAS_ORDERED_DICT
|
|||||||
|
|
||||||
REQUISITES = ['require', 'require_in', 'use', 'use_in', 'watch', 'watch_in']
|
REQUISITES = ['require', 'require_in', 'use', 'use_in', 'watch', 'watch_in']
|
||||||
|
|
||||||
OPTS = salt.config.master_config('whatever, just load the defaults!')
|
OPTS = salt.config.minion_config(None, check_dns=False)
|
||||||
# we should have used minion_config(), but that would try to resolve
|
|
||||||
# the master hostname, and retry for 30 seconds! Lucily for our purpose,
|
|
||||||
# master conf or minion conf, it doesn't matter.
|
|
||||||
OPTS['id'] = 'whatever'
|
OPTS['id'] = 'whatever'
|
||||||
OPTS['file_client'] = 'local'
|
OPTS['file_client'] = 'local'
|
||||||
OPTS['file_roots'] = dict(base=['/tmp'])
|
OPTS['file_roots'] = dict(base=['/tmp'])
|
||||||
@ -30,8 +27,6 @@ def render_sls(content, sls='', env='base', **kws):
|
|||||||
StringIO(content), env=env, sls=sls,
|
StringIO(content), env=env, sls=sls,
|
||||||
**kws)
|
**kws)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PyDSLRendererTestCase(TestCase):
|
class PyDSLRendererTestCase(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -91,7 +86,7 @@ state('G').service.watch_in(state('A').cmd)
|
|||||||
state('H').cmd.require_in('cmd', 'echo hello')
|
state('H').cmd.require_in('cmd', 'echo hello')
|
||||||
state('H').cmd.run('echo world')
|
state('H').cmd.run('echo world')
|
||||||
''')
|
''')
|
||||||
self.assertTrue(len(result), 6)
|
self.assertTrue(len(result), 6)
|
||||||
self.assertTrue(set("X A B G H".split()).issubset(set(result.keys())))
|
self.assertTrue(set("X A B G H".split()).issubset(set(result.keys())))
|
||||||
b = result['B']['cmd']
|
b = result['B']['cmd']
|
||||||
self.assertEqual(b[0], 'run')
|
self.assertEqual(b[0], 'run')
|
||||||
@ -280,14 +275,14 @@ state('.C').cmd.run('echo C >> {2}', cwd='/')
|
|||||||
sys.modules['salt.loaded.int.render.pydsl'].__salt__ = HIGHSTATE.state.functions
|
sys.modules['salt.loaded.int.render.pydsl'].__salt__ = HIGHSTATE.state.functions
|
||||||
|
|
||||||
high, errors = HIGHSTATE.render_highstate({'base': ['aaa']})
|
high, errors = HIGHSTATE.render_highstate({'base': ['aaa']})
|
||||||
# import pprint
|
# import pprint
|
||||||
# pprint.pprint(errors)
|
# pprint.pprint(errors)
|
||||||
# pprint.pprint(high)
|
# pprint.pprint(high)
|
||||||
out = HIGHSTATE.state.call_high(high)
|
out = HIGHSTATE.state.call_high(high)
|
||||||
# pprint.pprint(out)
|
# pprint.pprint(out)
|
||||||
with open(output, 'r') as f:
|
with open(output, 'r') as f:
|
||||||
self.assertEqual(''.join(f.read().split()), "XYZABCDEF")
|
self.assertEqual(''.join(f.read().split()), "XYZABCDEF")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
shutil.rmtree(dirpath, ignore_errors=True)
|
shutil.rmtree(dirpath, ignore_errors=True)
|
||||||
|
|
||||||
|
@ -10,11 +10,7 @@ import salt.config
|
|||||||
|
|
||||||
REQUISITES = ['require', 'require_in', 'use', 'use_in', 'watch', 'watch_in']
|
REQUISITES = ['require', 'require_in', 'use', 'use_in', 'watch', 'watch_in']
|
||||||
|
|
||||||
OPTS = salt.config.master_config('whatever, just load the defaults!')
|
OPTS = salt.config.minion_config(None, check_dns=False)
|
||||||
# we should have used minion_config(), but that would try to resolve
|
|
||||||
# the master hostname, and retry for 30 seconds! Lucily for our purpose,
|
|
||||||
# master conf or minion conf, it doesn't matter.
|
|
||||||
|
|
||||||
OPTS['file_client'] = 'local'
|
OPTS['file_client'] = 'local'
|
||||||
OPTS['file_roots'] = dict(base=['/'])
|
OPTS['file_roots'] = dict(base=['/'])
|
||||||
|
|
||||||
@ -175,13 +171,13 @@ extend:
|
|||||||
self.assertTrue('test.utils::some_state' in result['extend'])
|
self.assertTrue('test.utils::some_state' in result['extend'])
|
||||||
|
|
||||||
|
|
||||||
def test_start_state_generation(self):
|
def test_start_state_generation(self):
|
||||||
if sys.version_info < (2, 7) and not HAS_ORDERED_DICT:
|
if sys.version_info < (2, 7) and not HAS_ORDERED_DICT:
|
||||||
self.skipTest('OrderedDict is not available')
|
self.skipTest('OrderedDict is not available')
|
||||||
result = render_sls('''
|
result = render_sls('''
|
||||||
A:
|
A:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- name: echo hello
|
- name: echo hello
|
||||||
- cwd: /
|
- cwd: /
|
||||||
B:
|
B:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
|
Loading…
Reference in New Issue
Block a user