This commit is contained in:
Kovid Goyal 2023-09-17 13:38:51 +05:30
parent 0f76bf19f8
commit 33072bf70e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import os
import shutil
import tempfile
import time
from operator import itemgetter
from calibre.db.tests.base import BaseTest
from calibre.utils.resources import get_image_path
@ -135,6 +136,7 @@ def test_cache_api(self: 'NotesTest'):
note_id = cache.import_note('authors', author_id, f.name)
self.assertGreater(note_id, 0)
self.assertIn('<p>test simple exim <img', cache.notes_for('authors', author_id))
res = tuple(cache.get_notes_resource(x) for x in cache.notes_resources_used_by('authors', author_id))
exported = cache.export_note('authors', author_id)
self.assertIn('<p>test simple exim <img src="', exported)
from html5_parser import parse
@ -147,10 +149,8 @@ def test_cache_api(self: 'NotesTest'):
note_id = cache.import_note('authors', author_id, f.name)
self.assertGreater(note_id, 0)
self.assertIn('<p>test simple exim <img', cache.notes_for('authors', author_id))
res = set()
for x in cache.notes_resources_used_by('authors', author_id):
res.add(cache.get_notes_resource(x)['name'])
self.ae(res, {'r 1.png', 'r 2.png'})
res2 = tuple(cache.get_notes_resource(x) for x in cache.notes_resources_used_by('authors', author_id))
self.ae(sorted(res, key=itemgetter('name')), sorted(res2, key=itemgetter('name')))
def test_fts(self: 'NotesTest'):

View File

@ -16,8 +16,7 @@ from qt.core import (
from calibre import fit_image, sanitize_file_name
from calibre.constants import config_dir, iswindows
from calibre.db.constants import DATA_DIR_NAME, DATA_FILE_PATTERN
from calibre.db.notes.connect import RESOURCE_URL_SCHEME
from calibre.db.constants import DATA_DIR_NAME, DATA_FILE_PATTERN, RESOURCE_URL_SCHEME
from calibre.ebooks import BOOK_EXTENSIONS
from calibre.ebooks.metadata.book.base import Metadata, field_metadata
from calibre.ebooks.metadata.book.render import mi_to_html

View File

@ -12,7 +12,7 @@ from qt.core import (
)
from calibre import fit_image
from calibre.db.notes.connect import RESOURCE_URL_SCHEME
from calibre.db.constants import RESOURCE_URL_SCHEME
from calibre.gui2 import NO_URL_FORMATTING, gprefs
from calibre.gui2.book_details import (
create_open_cover_with_menu, resolved_css, details_context_menu_event, render_html, set_html,