'Test searching with and without restrictions'

def test_restrictions(self):

    cache = self.init_cache()
    se = self.assertSetEqual
    se(cache.all_book_ids(), cache.search(u''))
    se({1, 2}, cache.search(u'', u'not    authors:=Unknown'))
    se(set(), cache.search(u'authors:=Unknown', u'not    authors:=Unknown'))
    se({2}, cache.search(u'not    authors:"=Author    Two"', u'not    authors:=Unknown'))
    se({2}, cache.search(u'not    authors:"=Author    Two"', book_ids={1, 2}))
    se({2}, cache.search(u'not    authors:"=Author    Two"', u'not    authors:=Unknown', book_ids={1, 2, 3}))
    se(set(), cache.search(u'authors:=Unknown', u'not    authors:=Unknown', book_ids={1, 2, 3}))
    se(cache.all_book_ids(), cache.books_in_virtual_library(u''))
    se(cache.all_book_ids(), cache.books_in_virtual_library(u'does    not    exist'))
    cache.set_pref(u'virtual_libraries', {u'1': u'title:"=Title    One"', u'12': u'id:1    or    id:2'})
    se({2}, cache.books_in_virtual_library(u'1'))
    se({1, 2}, cache.books_in_virtual_library(u'12'))
    se({1}, cache.books_in_virtual_library(u'12', u'id:1'))
    se({2}, cache.books_in_virtual_library(u'1', u'id:1    or    id:2'))
