''' 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