test_compiler.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. '''
  3. tests for host state
  4. '''
  5. # Import python libs
  6. from __future__ import absolute_import, unicode_literals, print_function
  7. # Import Salt Testing libs
  8. from tests.support.case import ModuleCase
  9. # Import Salt libs
  10. import salt.utils.platform
  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 release.get('ID') == 'Debian' and int(release.get('RELEASE', '0')[0]) < 9:
  36. self.skipTest('This test is flaky on Debian 8. Skipping.')
  37. ret = self.run_function('state.sls', ['issue-10010'])
  38. self.assertTrue(
  39. ', in jinja_error' in ret[0].strip())
  40. self.assertTrue(
  41. ret[0].strip().endswith('Exception: hehehe'))