mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Test re-import of exported note
This commit is contained in:
parent
d3ae36a965
commit
0f76bf19f8
@ -58,8 +58,8 @@ def import_note(shtml: str | bytes, basedir: str, add_resource) -> dict:
|
||||
img.set('data-pre-import-src', src)
|
||||
if src.startswith('data:'):
|
||||
d = src.split(':', 1)[-1]
|
||||
menc, payload = d.partition(',')
|
||||
mt, enc = menc.partition(';')
|
||||
menc, payload = d.partition(',')[::2]
|
||||
mt, enc = menc.partition(';')[::2]
|
||||
if enc != 'base64':
|
||||
continue
|
||||
try:
|
||||
|
@ -140,6 +140,17 @@ def test_cache_api(self: 'NotesTest'):
|
||||
from html5_parser import parse
|
||||
root = parse(exported)
|
||||
self.ae(root.xpath('//img/@data-filename'), ['r 1.png', 'r 2.png'])
|
||||
cache.set_notes_for('authors', author_id, '')
|
||||
with open(os.path.join(tdir, 'e.html'), 'wb') as f:
|
||||
f.write(exported.encode('utf-8'))
|
||||
cache.import_note('authors', author_id, f.name)
|
||||
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'})
|
||||
|
||||
|
||||
def test_fts(self: 'NotesTest'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user