'Test methods that are directly equivalent in the old and new interface'

def test_legacy_setters(self):

    from calibre.ebooks.metadata.book.base import Metadata
    from calibre.utils.date import now
    n = now()
    ndb = self.init_legacy(self.cloned_library)
    amap = ndb.new_api.get_id_map(u'authors')
    sorts = [(aid, (u's%d' % aid)) for aid in amap]
    db = self.init_old(self.cloned_library)
    run_funcs(self, db, ndb, ((u'+format_metadata', 1, u'FMT1', itemgetter(u'size')), (u'+format_metadata', 1, u'FMT2', itemgetter(u'size')), (u'+format_metadata', 2, u'FMT1', itemgetter(u'size')), (u'get_tags', 0), (u'get_tags', 1), (u'get_tags', 2), (u'is_tag_used', u'News'), (u'is_tag_used', u'xchkjgfh'), (u'bulk_modify_tags', (1,), [u't1'], [u'News']), (u'bulk_modify_tags', (2,), [u't1'], [u'Tag    One', u'Tag    Two']), (u'bulk_modify_tags', (3,), [u't1', u't2', u't3']), (db.clean,), (u'@all_tags',), (u'@tags', 0), (u'@tags', 1), (u'@tags', 2), (u'unapply_tags', 1, [u't1']), (u'unapply_tags', 2, [u'xxxx']), (u'unapply_tags', 3, [u't2', u't3']), (db.clean,), (u'@all_tags',), (u'@tags', 0), (u'@tags', 1), (u'@tags', 2), (u'update_last_modified', (1,), True, n), (u'update_last_modified', (3,), True, n), (u'metadata_last_modified', 1, True), (u'metadata_last_modified', 3, True), (u'set_sort_field_for_author', sorts[0][0], sorts[0][1]), (u'set_sort_field_for_author', sorts[1][0], sorts[1][1]), (u'set_sort_field_for_author', sorts[2][0], sorts[2][1]), (u'set_link_field_for_author', sorts[0][0], sorts[0][1]), (u'set_link_field_for_author', sorts[1][0], sorts[1][1]), (u'set_link_field_for_author', sorts[2][0], sorts[2][1]), (db.refresh,), (u'author_sort', 0), (u'author_sort', 1), (u'author_sort', 2)))
    omi = [db.get_metadata(x) for x in (0, 1, 2)]
    nmi = [ndb.get_metadata(x) for x in (0, 1, 2)]
    self.assertEqual([x.author_sort_map for x in omi], [x.author_sort_map for x in nmi])
    self.assertEqual([x.author_link_map for x in omi], [x.author_link_map for x in nmi])
    db.close()
    ndb = self.init_legacy(self.cloned_library)
    db = self.init_old(self.cloned_library)
    run_funcs(self, db, ndb, ((u'set_authors', 1, (u'author    one',)), (u'set_authors', 2, (u'author    two',), True, True, True), (u'set_author_sort', 3, u'new_aus'), (u'set_comment', 1, u''), (u'set_comment', 2, None), (u'set_comment', 3, u'<p>a    comment</p>'), (u'set_has_cover', 1, True), (u'set_has_cover', 2, True), (u'set_has_cover', 3, 1), (u'set_identifiers', 2, {u'test': u'', u'a': u'b'}), (u'set_identifiers', 3, {u'id': u'1', u'isbn': u'9783161484100'}), (u'set_identifiers', 1, {}), (u'set_languages', 1, (u'en',)), (u'set_languages', 2, ()), (u'set_languages', 3, (u'deu', u'spa', u'fra')), (u'set_pubdate', 1, None), (u'set_pubdate', 2, u'2011-1-7'), (u'set_series', 1, u'a    series    one'), (u'set_series', 2, u'another    series    [7]'), (u'set_series', 3, u'a    third    series'), (u'set_publisher', 1, u'publisher    two'), (u'set_publisher', 2, None), (u'set_publisher', 3, u'a    third    puB'), (u'set_rating', 1, 2.3), (u'set_rating', 2, 0), (u'set_rating', 3, 8), (u'set_timestamp', 1, None), (u'set_timestamp', 2, u'2011-1-7'), (u'set_uuid', 1, None), (u'set_uuid', 2, u'a    test    uuid'), (u'set_title', 1, u'title    two'), (u'set_title', 2, None), (u'set_title', 3, u'The    Test    Title'), (u'set_tags', 1, [u'a1', u'a2'], True), (u'set_tags', 2, [u'b1', u'tag    one'], False, False, False, True), (u'set_tags', 3, [u'A1']), (db.refresh,), (u'title', 0), (u'title', 1), (u'title', 2), (u'title_sort', 0), (u'title_sort', 1), (u'title_sort', 2), (u'authors', 0), (u'authors', 1), (u'authors', 2), (u'author_sort', 0), (u'author_sort', 1), (u'author_sort', 2), (u'has_cover', 3), (u'has_cover', 1), (u'has_cover', 2), (u'get_identifiers', 0), (u'get_identifiers', 1), (u'get_identifiers', 2), (u'pubdate', 0), (u'pubdate', 1), (u'pubdate', 2), (u'timestamp', 0), (u'timestamp', 1), (u'timestamp', 2), (u'publisher', 0), (u'publisher', 1), (u'publisher', 2), (u'rating', 0), (u'+rating', 1, (lambda x: (x or 0))), (u'rating', 2), (u'series', 0), (u'series', 1), (u'series', 2), (u'series_index', 0), (u'series_index', 1), (u'series_index', 2), (u'uuid', 0), (u'uuid', 1), (u'uuid', 2), (u'isbn', 0), (u'isbn', 1), (u'isbn', 2), (u'@tags', 0), (u'@tags', 1), (u'@tags', 2), (u'@all_tags',), (u'@get_all_identifier_types',), (u'set_title_sort', 1, u'Title    Two'), (u'set_title_sort', 2, None), (u'set_title_sort', 3, u'The    Test    Title_sort'), (u'set_series_index', 1, 2.3), (u'set_series_index', 2, 0), (u'set_series_index', 3, 8), (u'set_identifier', 1, u'moose', u'val'), (u'set_identifier', 2, u'test', u''), (u'set_identifier', 3, u'', u''), (db.refresh,), (u'series_index', 0), (u'series_index', 1), (u'series_index', 2), (u'title_sort', 0), (u'title_sort', 1), (u'title_sort', 2), (u'get_identifiers', 0), (u'get_identifiers', 1), (u'get_identifiers', 2), (u'@get_all_identifier_types',), (u'set_metadata', 1, Metadata(u'title', (u'a1',)), False, False, False, True, True), (u'set_metadata', 3, Metadata(u'title', (u'a1',))), (db.refresh,), (u'title', 0), (u'title', 1), (u'title', 2), (u'title_sort', 0), (u'title_sort', 1), (u'title_sort', 2), (u'authors', 0), (u'authors', 1), (u'authors', 2), (u'author_sort', 0), (u'author_sort', 1), (u'author_sort', 2), (u'@tags', 0), (u'@tags', 1), (u'@tags', 2), (u'@all_tags',), (u'@get_all_identifier_types',)))
    db.close()
    ndb = self.init_legacy(self.cloned_library)
    db = self.init_old(self.cloned_library)
    run_funcs(self, db, ndb, ((u'set', 0, u'title', u'newtitle'), (u'set', 0, u'tags', u't1,t2,tag    one', True), (u'set', 0, u'authors', u'author    one    &    Author    Two', True), (u'set', 0, u'rating', 3.2), (u'set', 0, u'publisher', u'publisher    one', False), (db.refresh,), (u'title', 0), (u'rating', 0), (u'#tags', 0), (u'#tags', 1), (u'#tags', 2), (u'authors', 0), (u'authors', 1), (u'authors', 2), (u'publisher', 0), (u'publisher', 1), (u'publisher', 2), (u'delete_tag', u'T1'), (u'delete_tag', u'T2'), (u'delete_tag', u'Tag    one'), (u'delete_tag', u'News'), (db.clean,), (db.refresh,), (u'@all_tags',), (u'#tags', 0), (u'#tags', 1), (u'#tags', 2)))
    db.close()
    ndb = self.init_legacy(self.cloned_library)
    db = self.init_old(self.cloned_library)
    run_funcs(self, db, ndb, ((u'remove_all_tags', (1, 2, 3)), (db.clean,), (u'@all_tags',), (u'@tags', 0), (u'@tags', 1), (u'@tags', 2)))
    db.close()
    ndb = self.init_legacy(self.cloned_library)
    db = self.init_old(self.cloned_library)
    a = {v: k for (k, v) in ndb.new_api.get_id_map(u'authors').iteritems()}[u'Author    One']
    t = {v: k for (k, v) in ndb.new_api.get_id_map(u'tags').iteritems()}[u'Tag    One']
    s = {v: k for (k, v) in ndb.new_api.get_id_map(u'series').iteritems()}[u'A    Series    One']
    p = {v: k for (k, v) in ndb.new_api.get_id_map(u'publisher').iteritems()}[u'Publisher    One']
    run_funcs(self, db, ndb, ((u'rename_author', a, u'Author    Two'), (u'rename_tag', t, u'News'), (u'rename_series', s, u'ss'), (u'rename_publisher', p, u'publisher    one'), (db.clean,), (db.refresh,), (u'@all_tags',), (u'tags', 0), (u'tags', 1), (u'tags', 2), (u'series', 0), (u'series', 1), (u'series', 2), (u'publisher', 0), (u'publisher', 1), (u'publisher', 2), (u'series_index', 0), (u'series_index', 1), (u'series_index', 2), (u'authors', 0), (u'authors', 1), (u'authors', 2), (u'author_sort', 0), (u'author_sort', 1), (u'author_sort', 2)))
    db.close()
