test_compiler.py 1.6 KB

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