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.
35 lines
1.0 KiB
35 lines
1.0 KiB
import pytest |
|
|
|
|
|
@pytest.mark.parametrize( |
|
'value,expected', [ |
|
(None, None), |
|
([1, 2, 3], '[1, 2, 3]'), |
|
({'a':1, 'b':2}, '{"a": 1, "b": 2}'), |
|
] |
|
) |
|
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]), |
|
('{"a": 1, "b":2}', {'a':1, 'b':2}), |
|
] |
|
) |
|
def test_json_encoder_result(value, expected): |
|
from ordr.models.meta import JsonEncoder |
|
encoder = JsonEncoder() |
|
assert encoder.process_result_value(value, None) == expected |
|
|
|
|
|
@pytest.mark.parametrize('value', [None, [1, 2, 3], {'a':1, 'b':2}]) |
|
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
|
|
|