test_yaml_out.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. """
  3. unittests for yaml outputter
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import
  7. # Import Salt Libs
  8. import salt.output.yaml_out as yaml
  9. # Import Salt Testing Libs
  10. from tests.support.mixins import LoaderModuleMockMixin
  11. from tests.support.mock import patch
  12. from tests.support.unit import TestCase
  13. class YamlTestCase(TestCase, LoaderModuleMockMixin):
  14. """
  15. Test cases for salt.output.json_out
  16. """
  17. def setup_loader_modules(self):
  18. return {yaml: {}}
  19. def setUp(self):
  20. self.data = {"test": "two", "example": "one"}
  21. self.addCleanup(delattr, self, "data")
  22. def test_default_output(self):
  23. ret = yaml.output(self.data)
  24. expect = "example: one\ntest: two\n"
  25. self.assertEqual(expect, ret)
  26. def test_negative_int_output(self):
  27. with patch.dict(yaml.__opts__, {"output_indent": -1}):
  28. ret = yaml.output(self.data)
  29. expect = "{example: one, test: two}\n"
  30. self.assertEqual(expect, ret)