This commit is contained in:
Kovid Goyal 2023-08-22 12:53:46 +05:30
parent bff37a8054
commit cfadc5fc4d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -4,15 +4,18 @@
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
import inspect, time, numbers import inspect
from io import BytesIO import numbers
import time
from functools import partial from functools import partial
from io import BytesIO
from operator import itemgetter from operator import itemgetter
from calibre.library.field_metadata import fm_as_dict from calibre.db.constants import NOTES_DIR_NAME
from calibre.db.tests.base import BaseTest from calibre.db.tests.base import BaseTest
from polyglot.builtins import iteritems from calibre.library.field_metadata import fm_as_dict
from polyglot import reprlib from polyglot import reprlib
from polyglot.builtins import iteritems
# Utils {{{ # Utils {{{
@ -184,8 +187,9 @@ class LegacyTest(BaseTest):
def test_legacy_direct(self): # {{{ def test_legacy_direct(self): # {{{
'Test read-only methods that are directly equivalent in the old and new interface' 'Test read-only methods that are directly equivalent in the old and new interface'
from calibre.ebooks.metadata.book.base import Metadata
from datetime import timedelta from datetime import timedelta
from calibre.ebooks.metadata.book.base import Metadata
ndb = self.init_legacy(self.cloned_library) ndb = self.init_legacy(self.cloned_library)
db = self.init_old() db = self.init_old()
newstag = ndb.new_api.get_item_id('tags', 'news') newstag = ndb.new_api.get_item_id('tags', 'news')
@ -274,8 +278,8 @@ class LegacyTest(BaseTest):
def f(x, y): # get_top_level_move_items is broken in the old db on case-insensitive file systems def f(x, y): # get_top_level_move_items is broken in the old db on case-insensitive file systems
x.discard('metadata_db_prefs_backup.json') x.discard('metadata_db_prefs_backup.json')
y.pop('full-text-search.db', None) y.pop('full-text-search.db', None)
x.discard('.notes') x.discard(NOTES_DIR_NAME)
y.pop('.notes', None) y.pop(NOTES_DIR_NAME, None)
return x, y return x, y
self.assertEqual(f(*db.get_top_level_move_items()), f(*ndb.get_top_level_move_items())) self.assertEqual(f(*db.get_top_level_move_items()), f(*ndb.get_top_level_move_items()))
d1, d2 = BytesIO(), BytesIO() d1, d2 = BytesIO(), BytesIO()