set_cover()

This commit is contained in:
Kovid Goyal 2013-07-18 14:52:09 +05:30
parent aefab3b47a
commit 1ee4cad632
2 changed files with 10 additions and 1 deletions

View File

@ -667,7 +667,12 @@ class LibraryDatabase(object):
def remove_cover(self, book_id, notify=True, commit=True):
self.new_api.set_cover({book_id:None})
if notify:
self.notify('cover', [id])
self.notify('cover', [book_id])
def set_cover(self, book_id, data, notify=True, commit=True):
self.new_api.set_cover({book_id:data})
if notify:
self.notify('cover', [book_id])
# Private interface {{{
def __iter__(self):

View File

@ -346,10 +346,14 @@ class LegacyTest(BaseTest):
self.assertEqual(cache.field_for('tags', bid), (_('News'), 'Events', 'one', 'two'))
self.assertTrue(legacy.cover(1, index_is_id=True))
origcov = legacy.cover(1, index_is_id=True)
self.assertTrue(legacy.has_cover(1))
legacy.remove_cover(1)
self.assertFalse(legacy.has_cover(1))
self.assertFalse(legacy.cover(1, index_is_id=True))
legacy.set_cover(3, origcov)
self.assertEqual(legacy.cover(3, index_is_id=True), origcov)
self.assertTrue(legacy.has_cover(3))
legacy.delete_book(1)
old.delete_book(1)