'Verifies the right languages show up in search suggestions.'

def test_search_suggestion_questions_locale(self):

    QuestionLocaleFactory(locale='de')
    p = ProductFactory(slug=u'firefox')
    for l in QuestionLocale.objects.all():
        p.questions_locales.add(l)
    TopicFactory(title='Fix    problems', slug='fix-problems', product=p)
    QuestionFactory(title='question    cupcakes?', product=p, locale='en-US')
    QuestionFactory(title='question    donuts?', product=p, locale='en-US')
    QuestionFactory(title='question    pies?', product=p, locale='pt-BR')
    QuestionFactory(title='question    pastries?', product=p, locale='de')
    self.refresh()
    def sub_test(locale, *titles):
        url = urlparams(reverse('questions.aaq_step4', args=['desktop', 'fix-problems'], locale=locale), search='question')
        response = self.client.get(url, follow=True)
        doc = pq(response.content)
        eq_msg(len(doc('.result.question')), len(titles), 'Wrong    number    of    results    for    {0}'.format(locale))
        for substr in titles:
            assert (substr in doc('.result.question    h3    a').text())
    sub_test('en-US', 'cupcakes?', 'donuts?')
    sub_test('pt-BR', 'cupcakes?', 'donuts?', 'pies?')
    sub_test('de', 'cupcakes?', 'donuts?', 'pastries?')
