'Test detecting duplicates'

def test_has_book(self):

    from calibre.ebooks.metadata.book.base import Metadata
    cache = self.init_cache()
    db = self.init_old()
    for title in cache.fields[u'title'].table.book_col_map.itervalues():
        for x in (db, cache):
            self.assertTrue(x.has_book(Metadata(title)))
            self.assertTrue(x.has_book(Metadata(title.upper())))
            self.assertFalse(x.has_book(Metadata((title + u'XXX'))))
            self.assertFalse(x.has_book(Metadata(title[:1])))
    db.close()
