'Test for ajax endpoint with search parameter.'

def test_gallery_image_search(self):

    img = ImageFactory()
    url = urlparams(reverse('gallery.async'), type='image', q='foobar')
    response = self.client.get(url, follow=True)
    eq_(200, response.status_code)
    doc = pq(response.content)
    imgs = doc('#media-list    li    img')
    eq_(0, len(imgs))
    url = urlparams(reverse('gallery.async'), type='image', q=img.title)
    response = self.client.get(url, follow=True)
    eq_(200, response.status_code)
    doc = pq(response.content)
    imgs = doc('#media-list    li    img')
    eq_(1, len(imgs))
    eq_(img.thumbnail_url_if_set(), imgs[0].attrib['src'])
