Legacy implementations of a few direct methods

This commit is contained in:
Kovid Goyal 2013-07-07 11:44:30 +05:30
parent 3b438889a4
commit e64ff83e07
2 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,9 @@ class LibraryDatabase(object):
setattr(self, prop, partial(self.get_property,
loc=self.FIELD_MAP[fm]))
for meth in ('get_next_series_num_for', 'has_book', 'author_sort_from_authors'):
setattr(self, meth, getattr(self.new_api, meth))
self.last_update_check = self.last_modified()
def close(self):

View File

@ -103,6 +103,22 @@ class LegacyTest(BaseTest):
# }}}
def test_legacy_direct(self): # {{{
'Test methods that are directly equivalent in the old and new interface'
from calibre.ebooks.metadata.book.base import Metadata
ndb = self.init_legacy()
db = self.init_old()
for meth, args in {
'get_next_series_num_for': [('A Series One',)],
'author_sort_from_authors': [(['Author One', 'Author Two', 'Unknown'],)],
'has_book':[(Metadata('title one'),), (Metadata('xxxx1111'),)],
}.iteritems():
for a in args:
self.assertEqual(getattr(db, meth)(*a), getattr(ndb, meth)(*a),
'The method: %s() returned different results for argument %s' % (meth, a))
db.close()
# }}}
def test_legacy_coverage(self): # {{{
' Check that the emulation of the legacy interface is (almost) total '
cl = self.cloned_library