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.
48 lines
1.1 KiB
48 lines
1.1 KiB
7 years ago
|
''' Tests for ordr2.models.meta '''
|
||
|
|
||
|
import pytest
|
||
|
|
||
|
|
||
|
# tests for JsonEncoder
|
||
|
|
||
|
def test_json_encoder_bind_value():
|
||
|
''' test encoding to database for a given value '''
|
||
|
from ordr2.models.meta import JsonEncoder
|
||
|
|
||
|
encoder = JsonEncoder()
|
||
|
result = encoder.process_bind_param({'a': 'b'}, None)
|
||
|
|
||
|
assert result == '{"a": "b"}'
|
||
|
|
||
|
|
||
|
def test_json_encoder_bind_none():
|
||
|
''' test encoding to database if the given value is None '''
|
||
|
from ordr2.models.meta import JsonEncoder
|
||
|
|
||
|
encoder = JsonEncoder()
|
||
|
result = encoder.process_bind_param(None, None)
|
||
|
|
||
|
assert result is None
|
||
|
|
||
|
|
||
|
def test_json_encoder_result_value():
|
||
|
''' test encoding from database for a stored value '''
|
||
|
from ordr2.models.meta import JsonEncoder
|
||
|
|
||
|
json_string = '{"a": "b"}'
|
||
|
encoder = JsonEncoder()
|
||
|
result = encoder.process_result_value(json_string, None)
|
||
|
|
||
|
assert result == {'a': 'b'}
|
||
|
|
||
|
|
||
|
def test_json_encoder_result_none():
|
||
|
''' test encoding from database if the stored value is None '''
|
||
|
from ordr2.models.meta import JsonEncoder
|
||
|
|
||
|
encoder = JsonEncoder()
|
||
|
result = encoder.process_result_value(None, None)
|
||
|
|
||
|
assert result is None
|
||
|
|