def to_python(self, value): if isinstance(value, bytes): return mariadb_dyncol.unpack(value) elif isinstance(value, str): return json.loads(value) # serialization framework return value
def to_python(self, value): if isinstance(value, six.binary_type): return mariadb_dyncol.unpack(value) elif isinstance(value, six.text_type): return json.loads(value) # serialization framework return value
def check_data(data): packed = pack(data) check_against_db(data, packed) assert unpack(packed) == data
def test_unknown_columns_format(): with pytest.raises(DynColValueError): # Numbered columns format as pulled from MariaDB tests unpack(b'0001000100030861666166')
def test_unpack_Decimal_not_implemented(): with pytest.raises(DynColNotSupported): # Contains Decimal 1 unpack(unhexs(b'04010001000000040061090080000001'))
def test_non_unicode_charset_fails(): with pytest.raises(DynColNotSupported): unpack(unhexs('040100010000000300610861')) # {'a': 'a'} in latin1
def test_unicode_utf8mb4_unpack(): # All tests are using utf8 on connection but we should recognize utf8mb4 # as well assert unpack(unhexs('040100010000000300612d61')) == {"a": "a"}