mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add test for serialization of field metadata
This commit is contained in:
parent
c5dd2977eb
commit
a8b29afc50
@ -239,7 +239,12 @@ class ReadingTest(BaseTest):
|
||||
|
||||
def test_serialize_metadata(self): # {{{
|
||||
from calibre.utils.serialize import json_dumps, json_loads, msgpack_dumps, msgpack_loads
|
||||
from calibre.library.field_metadata import fm_as_dict
|
||||
cache = self.init_cache(self.library_path)
|
||||
fm = cache.field_metadata
|
||||
for d, l in ((json_dumps, json_loads), (msgpack_dumps, msgpack_loads)):
|
||||
fm2 = l(d(fm))
|
||||
self.assertEqual(fm_as_dict(fm), fm_as_dict(fm2))
|
||||
for i in xrange(1, 4):
|
||||
mi = cache.get_metadata(i, get_cover=True, cover_as_data=True)
|
||||
rmi = msgpack_loads(msgpack_dumps(mi))
|
||||
|
@ -433,10 +433,10 @@ class FieldMetadata(object):
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, FieldMetadata):
|
||||
return False
|
||||
for attr in ('_tb_cats', '_tb_custom_fields', '_search_term_map', 'custom_label_to_key_map', 'custom_field_prefix'):
|
||||
for attr in ('_tb_custom_fields', '_search_term_map', 'custom_label_to_key_map', 'custom_field_prefix'):
|
||||
if getattr(self, attr) != getattr(other, attr):
|
||||
return False
|
||||
return True
|
||||
return dict(self._tb_cats) == dict(other._tb_cats)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
Loading…
x
Reference in New Issue
Block a user