1
0

test_match.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Pedro Algarvio (pedro@algarvio.me)
  4. tests.integration.states.match
  5. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. """
  7. from __future__ import absolute_import, print_function, unicode_literals
  8. import os
  9. import salt.utils.files
  10. import salt.utils.stringutils
  11. from tests.support.case import ModuleCase
  12. from tests.support.helpers import skip_if_not_root, slowTest
  13. from tests.support.runtests import RUNTIME_VARS
  14. class StateMatchTest(ModuleCase):
  15. """
  16. Validate the file state
  17. """
  18. @skip_if_not_root
  19. @slowTest
  20. def test_issue_2167_ipcidr_no_AttributeError(self):
  21. subnets = self.run_function("network.subnets")
  22. self.assertTrue(len(subnets) > 0)
  23. top_filename = "issue-2167-ipcidr-match.sls"
  24. top_file = os.path.join(RUNTIME_VARS.BASE_FILES, top_filename)
  25. try:
  26. with salt.utils.files.fopen(top_file, "w") as fp_:
  27. fp_.write(
  28. salt.utils.stringutils.to_str(
  29. "base:\n"
  30. " {0}:\n"
  31. " - match: ipcidr\n"
  32. " - test\n".format(subnets[0])
  33. )
  34. )
  35. ret = self.run_function("state.top", [top_filename])
  36. self.assertNotIn(
  37. "AttributeError: 'Matcher' object has no attribute " "'functions'", ret
  38. )
  39. finally:
  40. os.remove(top_file)