'Test setting of cover'

def test_set_cover(self):

    cache = self.init_cache()
    ae = self.assertEqual
    ae(cache.field_for(u'cover', 1), 1)
    ae(cache.set_cover({1: None}), set([1]))
    ae(cache.field_for(u'cover', 1), 0)
    img = IMG
    ae(cache.set_cover({bid: img for bid in (1, 2, 3)}), {1, 2, 3})
    old = self.init_old()
    for book_id in (1, 2, 3):
        ae(cache.cover(book_id), img, (u'Cover    was    not    set    correctly    for    book    %d' % book_id))
        ae(cache.field_for(u'cover', book_id), 1)
        ae(old.cover(book_id, index_is_id=True), img, (u'Cover    was    not    set    correctly    for    book    %d' % book_id))
        self.assertTrue(old.has_cover(book_id))
    old.close()
    old.break_cycles()
    del old
