mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add test case for serializer_opts
This commit is contained in:
parent
e6ad0b2b0c
commit
700f71dd5f
@ -21,6 +21,7 @@ from tests.support.unit import skipIf, TestCase
|
||||
from tests.support.mock import (
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
Mock,
|
||||
MagicMock,
|
||||
call,
|
||||
mock_open,
|
||||
@ -84,6 +85,20 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
filestate.serialize('/tmp', dataset, formatter="python")
|
||||
self.assertEqual(returner.returned, pprint.pformat(dataset) + '\n')
|
||||
|
||||
mock_serializer = Mock(return_value='')
|
||||
with patch.dict(filestate.__serializers__,
|
||||
{'json.serialize': mock_serializer}):
|
||||
filestate.serialize(
|
||||
'/tmp',
|
||||
dataset,
|
||||
formatter='json',
|
||||
serializer_opts=[{'indent': 8}])
|
||||
mock_serializer.assert_called_with(
|
||||
dataset,
|
||||
indent=8,
|
||||
separators=(',', ': '),
|
||||
sort_keys=True)
|
||||
|
||||
def test_contents_and_contents_pillar(self):
|
||||
def returner(contents, *args, **kwargs):
|
||||
returner.returned = contents
|
||||
|
Loading…
Reference in New Issue
Block a user