def test_search_suggestion_questions_locale(self): """Verifies the right languages show up in search suggestions.""" questionlocale(locale='de', save=True) p = product(slug=u'firefox', save=True) for l in QuestionLocale.objects.all(): p.questions_locales.add(l) topic(title='Fix problems', slug='fix-problems', product=p, save=True) q1 = question(title='question cupcakes?', product=p, save=True, locale='en-US') q2 = question(title='question donuts?', product=p, save=True, locale='en-US') q3 = question(title='question pies?', product=p, save=True, locale='pt-BR') q4 = question(title='question pastries?', product=p, save=True, 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?')
def test_search_suggestion_questions_locale(self): """Verifies the right languages show up in search suggestions.""" questionlocale(locale='de', save=True) p = product(slug=u'firefox', save=True) for l in QuestionLocale.objects.all(): p.questions_locales.add(l) topic(title='Fix problems', slug='fix-problems', product=p, save=True) question( title='question cupcakes?', product=p, save=True, locale='en-US') question( title='question donuts?', product=p, save=True, locale='en-US') question( title='question pies?', product=p, save=True, locale='pt-BR') question( title='question pastries?', product=p, save=True, 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?')