1
0

test_compiler.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. """
  3. tests for host state
  4. """
  5. # Import python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt libs
  8. import salt.utils.platform
  9. # Import Salt Testing libs
  10. from tests.support.case import ModuleCase
  11. # Import 3rd-Party libs
  12. HAS_LSB_RELEASE = True
  13. try:
  14. import lsb_release
  15. except ImportError:
  16. HAS_LSB_RELEASE = False
  17. class CompileTest(ModuleCase):
  18. """
  19. Validate the state compiler
  20. """
  21. def test_multi_state(self):
  22. """
  23. Test the error with multiple states of the same type
  24. """
  25. ret = self.run_function("state.sls", mods="fuzz.multi_state")
  26. # Verify that the return is a list, aka, an error
  27. self.assertIsInstance(ret, list)
  28. def test_jinja_deep_error(self):
  29. """
  30. Test when we have an error in a execution module
  31. called by jinja
  32. """
  33. if salt.utils.platform.is_linux() and HAS_LSB_RELEASE:
  34. release = lsb_release.get_distro_information()
  35. if (
  36. release.get("ID") == "Debian"
  37. and int(release.get("RELEASE", "0")[0]) < 9
  38. ):
  39. self.skipTest("This test is flaky on Debian 8. Skipping.")
  40. ret = self.run_function("state.sls", ["issue-10010"])
  41. self.assertTrue(", in jinja_error" in ret[0].strip())
  42. self.assertTrue(ret[0].strip().endswith("Exception: hehehe"))