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
|
2017-02-27 13:58:07 +00:00
|
|
|
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
|
2017-03-21 17:15:36 +00:00
|
|
|
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-03-22 12:12:36 +00:00
|
|
|
def setup_loader_modules(self):
|
|
|
|
return {yaml: {}}
|
2017-02-19 15:35:30 +00:00
|
|
|
|
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)
|