'Search questions for topics.'

def test_question_topics(self):

    p = ProductFactory()
    t1 = TopicFactory(slug='doesnotexist', product=p)
    t2 = TopicFactory(slug='cookies', product=p)
    t3 = TopicFactory(slug='sync', product=p)
    QuestionFactory(topic=t2)
    QuestionFactory(topic=t2)
    QuestionFactory(topic=t3)
    self.refresh()
    topic_vals = ((t1.slug, 0), (t2.slug, 2), (t3.slug, 1))
    qs = {'a': 1, 'w': 2, 'format': 'json'}
    for (topics, number) in topic_vals:
        qs.update({'topics': topics})
        response = self.client.get(reverse('search.advanced'), qs)
        eq_(number, json.loads(response.content)['total'])
