You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
7 years ago
|
import pytest
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize(
|
||
|
'value,expected', [
|
||
|
(None, None),
|
||
|
([1, 2, 3], '[1, 2, 3]'),
|
||
7 years ago
|
({'a': 1, 'b': 2}, '{"a": 1, "b": 2}'),
|
||
7 years ago
|
]
|
||
|
)
|
||
|
def test_json_encoder_bind(value, expected):
|
||
|
from ordr.models.meta import JsonEncoder
|
||
|
encoder = JsonEncoder()
|
||
|
assert encoder.process_bind_param(value, None) == expected
|
||
|
|
||
|
|
||
|
@pytest.mark.parametrize(
|
||
|
'value,expected', [
|
||
|
(None, None),
|
||
|
('[1, 2, 3]', [1, 2, 3]),
|
||
7 years ago
|
('{"a": 1, "b":2}', {'a': 1, 'b': 2}),
|
||
7 years ago
|
]
|
||
|
)
|
||
|
def test_json_encoder_result(value, expected):
|
||
|
from ordr.models.meta import JsonEncoder
|
||
|
encoder = JsonEncoder()
|
||
|
assert encoder.process_result_value(value, None) == expected
|
||
|
|
||
|
|
||
7 years ago
|
@pytest.mark.parametrize('value', [None, [1, 2, 3], {'a': 1, 'b': 2}])
|
||
7 years ago
|
def test_json_encoder_bind_and_result(value):
|
||
|
from ordr.models.meta import JsonEncoder
|
||
|
encoder = JsonEncoder()
|
||
|
result = encoder.process_bind_param(value, None)
|
||
|
assert encoder.process_result_value(result, None) == value
|