Example #1
0
    def test_search_suggestion_questions_locale(self):
        """Verifies the right languages show up in search suggestions."""
        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?')
Example #2
0
    def test_search_suggestion_questions_locale(self):
        """Verifies the right languages show up in search suggestions."""
        QuestionLocaleFactory(locale="de")

        product = ProductFactory(slug="firefox")

        for loc in QuestionLocale.objects.all():
            product.questions_locales.add(loc)

        TopicFactory(title="Fix problems",
                     slug="fix-problems",
                     product=product)

        QuestionFactory(title="question cupcakes?",
                        product=product,
                        locale="en-US")
        QuestionFactory(title="question donuts?",
                        product=product,
                        locale="en-US")
        QuestionFactory(title="question pies?",
                        product=product,
                        locale="pt-BR")
        QuestionFactory(title="question pastries?",
                        product=product,
                        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?")