test_jinja.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. from tests.support.unit import skipIf
  8. class JinjaRendererTest(ModuleCase):
  9. @with_tempdir()
  10. @skipIf(True, "SLOWTEST skip")
  11. @skipIf(True, "SLOWTEST skip")
  12. def test_issue_54765(self, tmpdir):
  13. file_path = os.path.join(tmpdir, "issue-54765")
  14. ret = self.run_function(
  15. "state.sls", mods="issue-54765", pillar={"file_path": file_path}
  16. )
  17. key = "file_|-issue-54765_|-{}_|-managed".format(file_path)
  18. assert key in ret
  19. assert ret[key]["result"] is True
  20. with salt.utils.files.fopen(file_path, "r") as fp:
  21. assert fp.read().strip() == "bar"
  22. class JinjaRenderCallTest(ShellCase):
  23. @with_tempdir()
  24. @skipIf(True, "SLOWTEST skip")
  25. @skipIf(True, "SLOWTEST skip")
  26. def test_issue_54765(self, tmpdir):
  27. file_path = os.path.join(tmpdir, "issue-54765")
  28. pillar_str = '\'{{"file_path": "{}"}}\''.format(file_path)
  29. ret = self.run_call(
  30. "state.apply issue-54765 pillar={}".format(pillar_str), local=True
  31. )
  32. assert " Result: True" in ret
  33. with salt.utils.files.fopen(file_path, "r") as fp:
  34. assert fp.read().strip() == "bar"