test_yaml_out.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. '''
  3. unittests for yaml outputter
  4. '''
  5. # Import Python Libs
  6. from __future__ import absolute_import
  7. # Import Salt Testing Libs
  8. from tests.support.mixins import LoaderModuleMockMixin
  9. from tests.support.unit import TestCase
  10. from tests.support.mock import patch
  11. # Import Salt Libs
  12. import salt.output.yaml_out as yaml
  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)