'Test /ajax/book'

def test_ajax_book(self):

    with self.create_server() as server:
        db = server.handler.router.ctx.library_broker.get(None)
        conn = server.connect()
        request = partial(make_request, conn, prefix=u'/ajax/book')
        (r, data) = request(u'/x')
        self.ae(r.status, httplib.NOT_FOUND)
        (r, onedata) = request(u'/1')
        self.ae(r.status, httplib.OK)
        self.ae(request((u'/1/' + db.server_library_id))[1], onedata)
        self.ae(request((u'/%s?id_is_uuid=true' % db.field_for(u'uuid', 1)))[1], onedata)
        (r, data) = request(u's')
        self.ae(set(data.iterkeys()), set(map(str, db.all_book_ids())))
        (r, zdata) = request(u's', headers={u'Accept-Encoding': u'gzip'})
        self.ae(r.getheader(u'Content-Encoding'), u'gzip')
        self.ae(json.loads(zlib.decompress(zdata, (16 + zlib.MAX_WBITS))), data)
        (r, data) = request(u's?ids=1,2')
        self.ae(set(data.iterkeys()), {u'1', u'2'})
