newdb: get_metadata() should have sorted formats list in mi.formats

This commit is contained in:
Kovid Goyal 2013-08-01 09:31:02 +05:30
parent 20f414a7f5
commit fda8ce7abb
3 changed files with 3 additions and 3 deletions

View File

@ -223,7 +223,7 @@ class Cache(object):
good_formats = None good_formats = None
else: else:
mi.format_metadata = FormatMetadata(self, book_id, formats) mi.format_metadata = FormatMetadata(self, book_id, formats)
good_formats = FormatsList(formats, mi.format_metadata) good_formats = FormatsList(sorted(formats), mi.format_metadata)
# These three attributes are returned by the db2 get_metadata(), # These three attributes are returned by the db2 get_metadata(),
# however, we dont actually use them anywhere other than templates, so # however, we dont actually use them anywhere other than templates, so
# they have been removed, to avoid unnecessary overhead. The templates # they have been removed, to avoid unnecessary overhead. The templates

View File

@ -175,7 +175,7 @@ def fmt_getter(field):
if m: if m:
format_metadata[fmt] = m format_metadata[fmt] = m
if field == 'formats': if field == 'formats':
return list(format_metadata) or None return sorted(format_metadata) or None
return format_metadata return format_metadata
return func return func

View File

@ -478,7 +478,7 @@ class ReadingTest(BaseTest):
for field in STANDARD_METADATA_FIELDS | {'#series_index'}: for field in STANDARD_METADATA_FIELDS | {'#series_index'}:
f = lambda x: x f = lambda x: x
if field == 'formats': if field == 'formats':
f = lambda x: x if x is None else set(x) f = lambda x: x if x is None else tuple(x)
self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)), self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)),
'Standard field: %s not the same for book %s' % (field, book_id)) 'Standard field: %s not the same for book %s' % (field, book_id))
self.assertEqual(mi.format_field(field), pmi.format_field(field), self.assertEqual(mi.format_field(field), pmi.format_field(field),