Пример #1
0
    def test_miscounting_archived(self):
        """
        Verify that the l10n overview readout treats archived docs consistently.

        Bug 1012384
        """
        locale = 'nl'
        parent1 = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, is_archived=False)
        translation1 = DocumentFactory(parent=parent1, locale=locale)
        parent2 = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, is_archived=True)
        translation2 = DocumentFactory(parent=parent2, locale=locale)

        trans_rev1 = ApprovedRevisionFactory(document=parent1, is_ready_for_localization=True)
        ApprovedRevisionFactory(document=translation1, based_on=trans_rev1)
        trans_rev2 = ApprovedRevisionFactory(document=parent2, is_ready_for_localization=True)
        ApprovedRevisionFactory(document=translation2, based_on=trans_rev2)

        # Document.save() will enforce that parents and translations share is_archived.
        # The point of this is to test what happens when that isn't true though,
        # so bypass Document.save().
        translation2.is_archived = False
        ModelBase.save(translation2)
        eq_(translation2.is_archived, False)

        overview = l10n_overview_rows(locale)
        eq_(1, overview['all']['denominator'])
        eq_(1, overview['all']['numerator'])
Пример #2
0
    def test_miscounting_archived(self):
        """
        Verify that the l10n overview readout treats archived docs consistently.

        Bug 1012384
        """
        locale = 'nl'
        parent1 = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, is_archived=False)
        translation1 = DocumentFactory(parent=parent1, locale=locale)
        parent2 = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, is_archived=True)
        translation2 = DocumentFactory(parent=parent2, locale=locale)

        trans_rev1 = ApprovedRevisionFactory(document=parent1, is_ready_for_localization=True)
        ApprovedRevisionFactory(document=translation1, based_on=trans_rev1)
        trans_rev2 = ApprovedRevisionFactory(document=parent2, is_ready_for_localization=True)
        ApprovedRevisionFactory(document=translation2, based_on=trans_rev2)

        # Document.save() will enforce that parents and translations share is_archived.
        # The point of this is to test what happens when that isn't true though,
        # so bypass Document.save().
        translation2.is_archived = False
        ModelBase.save(translation2)
        eq_(translation2.is_archived, False)

        overview = l10n_overview_rows(locale)
        eq_(1, overview['all']['denominator'])
        eq_(1, overview['all']['numerator'])
Пример #3
0
    def test_only_show_wiki_and_questions(self):
        """Tests that the simple search doesn't show forums

        This verifies that we're only showing documents of the type
        that should be shown and that the filters on model are working
        correctly.

        Bug #767394

        """
        p = ProductFactory(slug=u'desktop')
        ques = QuestionFactory(title=u'audio', product=p)
        ans = AnswerFactory(question=ques, content=u'volume')
        AnswerVoteFactory(answer=ans, helpful=True)

        doc = DocumentFactory(title=u'audio', locale=u'en-US', category=10)
        doc.products.add(p)
        RevisionFactory(document=doc, is_approved=True)

        thread1 = ThreadFactory(title=u'audio')
        PostFactory(thread=thread1)

        self.refresh()

        response = self.client.get(reverse('search'), {
            'q': 'audio',
            'format': 'json'
        })

        eq_(200, response.status_code)

        content = json.loads(response.content)
        eq_(content['total'], 2)

        # Archive the article and question. They should no longer appear
        # in simple search results.
        ques.is_archived = True
        ques.save()
        doc.is_archived = True
        doc.save()

        self.refresh()

        response = self.client.get(reverse('search'), {
            'q': 'audio',
            'format': 'json'
        })

        eq_(200, response.status_code)

        content = json.loads(response.content)
        eq_(content['total'], 0)
Пример #4
0
    def test_only_show_wiki_and_questions(self):
        """Tests that the simple search doesn't show forums

        This verifies that we're only showing documents of the type
        that should be shown and that the filters on model are working
        correctly.

        Bug #767394

        """
        p = ProductFactory(slug=u'desktop')
        ques = QuestionFactory(title=u'audio', product=p)
        ans = AnswerFactory(question=ques, content=u'volume')
        AnswerVoteFactory(answer=ans, helpful=True)

        doc = DocumentFactory(title=u'audio', locale=u'en-US', category=10)
        doc.products.add(p)
        RevisionFactory(document=doc, is_approved=True)

        thread1 = ThreadFactory(title=u'audio')
        PostFactory(thread=thread1)

        self.refresh()

        response = self.client.get(reverse('search'), {
            'q': 'audio', 'format': 'json'})

        eq_(200, response.status_code)

        content = json.loads(response.content)
        eq_(content['total'], 2)

        # Archive the article and question. They should no longer appear
        # in simple search results.
        ques.is_archived = True
        ques.save()
        doc.is_archived = True
        doc.save()

        self.refresh()

        response = self.client.get(reverse('search'), {
            'q': 'audio', 'format': 'json'})

        eq_(200, response.status_code)

        content = json.loads(response.content)
        eq_(content['total'], 0)
Пример #5
0
    def test_search_suggestions_questions(self):
        """Verifies the view doesn't kick up an HTTP 500"""
        p = ProductFactory(slug=u"firefox")
        locale = QuestionLocale.objects.get(locale=settings.LANGUAGE_CODE)
        p.questions_locales.add(locale)
        TopicFactory(title="Fix problems", slug="fix-problems", product=p)
        q = QuestionFactory(product=p, title=u"CupcakesQuestion cupcakes")

        d = DocumentFactory(title=u"CupcakesKB cupcakes", category=10)
        d.products.add(p)

        RevisionFactory(document=d, is_approved=True)

        self.refresh()

        url = urlparams(
            reverse("questions.aaq_step4", args=["desktop", "fix-problems"]),
            search="cupcakes",
        )

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        assert "CupcakesQuestion" in response.content
        assert "CupcakesKB" in response.content

        # Verify that archived articles and questions aren't shown...
        # Archive both and they shouldn't appear anymore.
        q.is_archived = True
        q.save()
        d.is_archived = True
        d.save()

        self.refresh()

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        assert "CupcakesQuestion" not in response.content
        assert "CupcakesKB" not in response.content
Пример #6
0
    def test_search_suggestions_questions(self):
        """Verifies the view doesn't kick up an HTTP 500"""
        p = ProductFactory(slug=u'firefox')
        l = QuestionLocale.objects.get(locale=settings.LANGUAGE_CODE)
        p.questions_locales.add(l)
        TopicFactory(title='Fix problems', slug='fix-problems', product=p)
        q = QuestionFactory(product=p, title=u'CupcakesQuestion cupcakes')

        d = DocumentFactory(title=u'CupcakesKB cupcakes', category=10)
        d.products.add(p)

        RevisionFactory(document=d, is_approved=True)

        self.refresh()

        url = urlparams(
            reverse('questions.aaq_step4', args=['desktop', 'fix-problems']),
            search='cupcakes')

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        assert 'CupcakesQuestion' in response.content
        assert 'CupcakesKB' in response.content

        # Verify that archived articles and questions aren't shown...
        # Archive both and they shouldn't appear anymore.
        q.is_archived = True
        q.save()
        d.is_archived = True
        d.save()

        self.refresh()

        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        assert 'CupcakesQuestion' not in response.content
        assert 'CupcakesKB' not in response.content