1
0

test_jinja.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. from __future__ import absolute_import, print_function, unicode_literals
  3. import os
  4. import salt.utils.files
  5. from tests.support.case import ModuleCase, ShellCase
  6. from tests.support.helpers import with_tempdir
  7. class JinjaRendererTest(ModuleCase):
  8. @with_tempdir()
  9. def test_issue_54765(self, tmpdir):
  10. file_path = os.path.join(tmpdir, 'issue-54765')
  11. ret = self.run_function('state.sls', mods='issue-54765', pillar={'file_path': file_path})
  12. key = 'file_|-issue-54765_|-{}_|-managed'.format(file_path)
  13. assert key in ret
  14. assert ret[key]['result'] is True
  15. with salt.utils.files.fopen(file_path, 'r') as fp:
  16. assert fp.read().strip() == 'bar'
  17. class JinjaRenderCallTest(ShellCase):
  18. @with_tempdir()
  19. def test_issue_54765(self, tmpdir):
  20. file_path = os.path.join(tmpdir, 'issue-54765')
  21. pillar_str = '\'{{"file_path": "{}"}}\''.format(file_path)
  22. ret = self.run_call('state.apply issue-54765 pillar={}'.format(pillar_str), local=True)
  23. assert ' Result: True' in ret
  24. with salt.utils.files.fopen(file_path, 'r') as fp:
  25. assert fp.read().strip() == 'bar'