mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add unit tests for table outputter
This commit is contained in:
parent
907d182dea
commit
d729656703
1 changed files with 48 additions and 0 deletions
48
tests/unit/output/test_table_out.py
Normal file
48
tests/unit/output/test_table_out.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
unittests for table outputter
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
from tests.support.unit import TestCase
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.output.table_out as table_out
|
||||
import salt.utils.stringutils
|
||||
|
||||
|
||||
class TableTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
Test cases for salt.output.table_out
|
||||
'''
|
||||
def setup_loader_modules(self):
|
||||
return {table_out: {}}
|
||||
|
||||
# The test data should include unicode chars, and in Python 2 there should
|
||||
# be an example both of an encoded str type and an actual unicode type.
|
||||
# Since unicode_literals is imported, we will achieve the former using
|
||||
# salt.utils.stringutils.to_str and the latter by simply using a string
|
||||
# literal.
|
||||
data = [
|
||||
{'Food': salt.utils.stringutils.to_str('яйца, бекон, колбаса и спам'),
|
||||
'Price': 5.99},
|
||||
{'Food': 'спам, спам, спам, яйца и спам',
|
||||
'Price': 3.99},
|
||||
]
|
||||
|
||||
def test_output(self):
|
||||
ret = table_out.output(self.data)
|
||||
self.assertEqual(
|
||||
ret,
|
||||
(' -----------------------------------------\n'
|
||||
' | Food | Price |\n'
|
||||
' -----------------------------------------\n'
|
||||
' | яйца, бекон, колбаса и спам | 5.99 |\n'
|
||||
' -----------------------------------------\n'
|
||||
' | спам, спам, спам, яйца и спам | 3.99 |\n'
|
||||
' -----------------------------------------')
|
||||
)
|
Loading…
Add table
Reference in a new issue