salt/tests/unit/output/test_yaml_out.py

38 lines
991 B
Python
Raw Normal View History

2016-10-07 14:52:53 +00:00
# -*- coding: utf-8 -*-
'''
unittests for yaml outputter
'''
# Import Python Libs
from __future__ import absolute_import
# Import Salt Testing Libs
2017-02-19 15:35:30 +00:00
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import TestCase
2017-02-19 15:35:30 +00:00
from tests.support.mock import patch
2016-10-07 14:52:53 +00:00
# Import Salt Libs
import salt.output.yaml_out as yaml
2016-10-07 14:52:53 +00:00
2016-10-12 08:14:45 +00:00
2017-02-19 15:35:30 +00:00
class YamlTestCase(TestCase, LoaderModuleMockMixin):
2016-10-07 14:52:53 +00:00
'''
Test cases for salt.output.json_out
'''
2017-02-19 15:35:30 +00:00
loader_module = yaml
2016-10-07 14:52:53 +00:00
def setUp(self):
self.data = {'test': 'two', 'example': 'one'}
2017-02-19 15:35:30 +00:00
self.addCleanup(delattr, self, 'data')
2016-10-07 14:52:53 +00:00
def test_default_output(self):
ret = yaml.output(self.data)
expect = 'example: one\ntest: two\n'
self.assertEqual(expect, ret)
def test_negative_int_output(self):
2017-02-19 15:35:30 +00:00
with patch.dict(yaml.__opts__, {'output_indent': -1}):
ret = yaml.output(self.data)
expect = '{example: one, test: two}\n'
self.assertEqual(expect, ret)