1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/units/module_utils/common/text/converters/test_jsonify.py
Andrey Klychkov 01ed7a489a Add unit tests for lib/ansible/module_utils/common/text/converters.py (#56915)
Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
2019-05-30 09:22:53 -04:00

27 lines
811 B
Python

# -*- coding: utf-8 -*-
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import pytest
from ansible.module_utils.common.text.converters import jsonify
@pytest.mark.parametrize(
'test_input,expected',
[
(1, '1'),
(u'string', u'"string"'),
(u'くらとみ', u'"\\u304f\\u3089\\u3068\\u307f"'),
(u'café', u'"caf\\u00e9"'),
(b'string', u'"string"'),
(False, u'false'),
(u'string'.encode('utf-8'), u'"string"'),
]
)
def test_jsonify(test_input, expected):
"""Test for jsonify()."""
assert jsonify(test_input) == expected