Ejemplo n.º 1
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done.
     """
     translated_revision(is_approved=False, save=True)
     overview = overview_rows('de')
     eq_(0, overview['most-visited']['numerator'])
     eq_(0, overview['all']['numerator'])
Ejemplo n.º 2
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done.
     """
     translated_revision(is_approved=False, save=True)
     overview = overview_rows('de')
     eq_(0, overview['most-visited']['numerator'])
     eq_(0, overview['all']['numerator'])
Ejemplo n.º 3
0
    def test_one_rejected_revision(self):
        """Translation with 1 rejected rev shows as Needs Translation"""
        translated_revision(is_approved=False,
                            reviewed=datetime.now(),
                            save=True)

        row = self.row()
        eq_(row['status_class'], 'untranslated')
Ejemplo n.º 4
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done.
     """
     translated_revision(is_approved=False, save=True)
     overview = l10n_overview_rows("de")
     eq_(0, overview["top-20"]["numerator"])
     eq_(0, overview["top-50"]["numerator"])
     eq_(0, overview["top-100"]["numerator"])
     eq_(0, overview["all"]["numerator"])
Ejemplo n.º 5
0
    def test_inheritance(self):
        """Make sure parent/child equality of is_archived is maintained."""
        # Set up a child and a parent and an orphan (all false) and something
        # true.
        translated_revision(save=True)
        translated_revision(save=True)
        document(save=True)
        document(is_archived=True, save=True)

        # Batch-clear the archival bits:
        DocumentAdmin._set_archival(Document.objects.all(), True)

        # Assert the child of the parent and the parent of the child (along
        # with everything else) became (or stayed) true:
        eq_(Document.objects.filter(is_archived=True).count(), 6)
Ejemplo n.º 6
0
    def test_inheritance(self):
        """Make sure parent/child equality of is_archived is maintained."""
        # Set up a child and a parent and an orphan (all false) and something
        # true.
        translated_revision(save=True)
        translated_revision(save=True)
        document(save=True)
        document(is_archived=True, save=True)

        # Batch-clear the archival bits:
        DocumentAdmin._set_archival(Document.objects.all(), True)

        # Assert the child of the parent and the parent of the child (along
        # with everything else) became (or stayed) true:
        eq_(Document.objects.filter(is_archived=True).count(), 6)
Ejemplo n.º 7
0
    def test_all_articles_doesnt_have_30_40_50(self):
        """Make sure All Articles doesn't have 30, 40, and 50 articles"""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        # ...but not when it's a navigation article:
        t.document.parent.title = t.document.title = 'thing'
        t.document.parent.category = t.document.category = 50
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or administration:
        t.document.parent.category = t.document.category = 40
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or how to contribute:
        t.document.parent.category = t.document.category = 30
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Ejemplo n.º 8
0
    def test_all_articles_doesnt_have_30_40_50(self):
        """Make sure All Articles doesn't have 30, 40, and 50 articles"""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        # ...but not when it's a navigation article:
        t.document.parent.title = t.document.title = 'thing'
        t.document.parent.category = t.document.category = 50
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or administration:
        t.document.parent.category = t.document.category = 40
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or how to contribute:
        t.document.parent.category = t.document.category = 30
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Ejemplo n.º 9
0
    def test_not_counting_outdated(self):
        """Out-of-date translations shouldn't count as "done".

        "Out-of-date" can mean either moderately or majorly out of date. The
        only thing we don't care about is typo-level outdatedness.

        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a typo-level revision:
        revision(document=t.document.parent,
                 significance=TYPO_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it still shows up in the numerators:
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a medium-level revision:
        revision(document=t.document.parent,
                 significance=MEDIUM_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it no longer shows up in the numerators:
        overview = overview_rows('de')
        eq_(0, overview['all']['numerator'])
        eq_(0, overview['most-visited']['numerator'])
Ejemplo n.º 10
0
    def test_not_counting_outdated(self):
        """Out-of-date translations shouldn't count as "done".

        "Out-of-date" can mean either moderately or majorly out of date. The
        only thing we don't care about is typo-level outdatedness.

        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a typo-level revision:
        revision(document=t.document.parent,
                 significance=TYPO_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it still shows up in the numerators:
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a medium-level revision:
        revision(document=t.document.parent,
                 significance=MEDIUM_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it no longer shows up in the numerators:
        overview = overview_rows('de')
        eq_(0, overview['all']['numerator'])
        eq_(0, overview['most-visited']['numerator'])
Ejemplo n.º 11
0
    def test_consider_max_significance(self):
        """Use max significance for determining change significance

        When determining how significantly an article has changed
        since translation, use the max significance of the approved
        revisions, not just that of the latest ready-to-localize one.
        """
        translation = translated_revision(is_approved=True, save=True)
        revision(
            document=translation.document.parent,
            is_approved=True,
            is_ready_for_localization=False,  # should still count
            significance=MAJOR_SIGNIFICANCE,
            save=True,
        )
        revision(
            document=translation.document.parent,
            is_approved=True,
            is_ready_for_localization=True,
            significance=MEDIUM_SIGNIFICANCE,
            save=True,
        )
        row = self.row()
        eq_(row["title"], translation.document.title)
        eq_(unicode(row["status"]), "Immediate Update Needed")
Ejemplo n.º 12
0
 def test_up_to_date(self):
     """Show up-to-date translations have no status, just a happy class.
     """
     translation = translated_revision(is_approved=True, save=True)
     row = self.row()
     eq_(row["title"], translation.document.title)
     eq_(unicode(row["status"]), "")
     eq_(row["status_class"], "ok")
Ejemplo n.º 13
0
    def test_redirects_are_ignored(self):
        """Verify that redirects aren't counted in the overview."""
        translated_revision(is_approved=True, save=True)

        eq_(1, overview_rows('de')['all']['numerator'])

        # A redirect shouldn't affect any of the tests.
        revision(document=document(title='A redirect',
                                   is_localizable=True,
                                   is_template=True,
                                   save=True),
                 is_ready_for_localization=True,
                 is_approved=True,
                 content='REDIRECT [[An article]]',
                 save=True)

        eq_(1, overview_rows('de')['all']['numerator'])
Ejemplo n.º 14
0
 def test_up_to_date(self):
     """Show up-to-date translations have no status, just a happy class.
     """
     translation = translated_revision(is_approved=True, save=True)
     row = self.row()
     eq_(row['title'], translation.document.title)
     eq_(unicode(row['status']), '')
     eq_(row['status_class'], 'ok')
Ejemplo n.º 15
0
    def test_redirects_are_ignored(self):
        """Verify that redirects aren't counted in the overview."""
        translated_revision(is_approved=True, save=True)

        eq_(1, overview_rows('de')['all']['numerator'])

        # A redirect shouldn't affect any of the tests.
        revision(document=document(title='A redirect',
                                   is_localizable=True,
                                   is_template=True,
                                   save=True),
                 is_ready_for_localization=True,
                 is_approved=True,
                 content='REDIRECT [[An article]]',
                 save=True)

        eq_(1, overview_rows('de')['all']['numerator'])
Ejemplo n.º 16
0
 def test_unrevieweds_after_current(self):
     """Show unreviewed revisions with later creation dates than current
     """
     current = translated_revision(is_approved=True, save=True,
                                   created=datetime(2000, 1, 1))
     unreviewed = revision(document=current.document, save=True,
                           created=datetime(2000, 2, 1))
     assert unreviewed.document.title in self.titles()
Ejemplo n.º 17
0
    def test_redirects_are_ignored(self):
        """Verify that redirects aren't counted in the overview."""
        translated_revision(is_approved=True, save=True)

        eq_(1, l10n_overview_rows("de")["all"]["numerator"])

        # A redirect shouldn't affect any of the tests.
        revision(
            document=document(title="A redirect", is_localizable=True, is_template=True, save=True),
            is_ready_for_localization=True,
            is_approved=True,
            content="REDIRECT [[An article]]",
            save=True,
        )

        overview = l10n_overview_rows("de")
        eq_(1, overview["all"]["numerator"])
        eq_(1, overview["top-20"]["numerator"])
        eq_(1, overview["top-50"]["numerator"])
        eq_(1, overview["top-100"]["numerator"])
Ejemplo n.º 18
0
    def test_by_product(self):
        """Test the product filtering of the readout."""
        p = product(title='Firefox', slug='firefox', save=True)
        unreviewed = translated_revision(save=True)

        # There shouldn't be any rows yet.
        eq_(0, len(self.rows(product=p)))

        # Add the product to the parent document, and verify it shows up.
        unreviewed.document.parent.products.add(p)
        eq_(self.row(product=p)['title'], unreviewed.document.title)
Ejemplo n.º 19
0
    def test_content_parsed_with_locale(self):
        """Make sure links to localized articles work."""
        rev = translated_revision(locale='es', is_approved=True, save=True)
        doc = rev.document
        doc.title = u'Un mejor título'
        doc.save()

        q = question(locale='es', save=True)
        a = answer(question=q, content='[[%s]]' % doc.title, save=True)

        assert 'es/kb/%s' % doc.slug in a.content_parsed
Ejemplo n.º 20
0
    def test_content_parsed_with_locale(self):
        """Make sure links to localized articles work."""
        rev = translated_revision(locale='es', is_approved=True, save=True)
        doc = rev.document
        doc.title = u'Un mejor título'
        doc.save()

        q = question(locale='es', save=True)
        a = answer(question=q, content='[[%s]]' % doc.title, save=True)

        assert 'es/kb/%s' % doc.slug in a.content_parsed
Ejemplo n.º 21
0
    def test_render(self):
        """Assert main dash and all the readouts render and don't crash."""
        # Put some stuff in the DB so at least one row renders for each
        # readout:
        unreviewed = translated_revision(is_ready_for_localization=True)
        unreviewed.save()

        response = self.client.get(reverse("dashboards.localization", locale="de"), follow=False)
        eq_(200, response.status_code)
        doc = pq(response.content)
        self._assert_readout_contains(doc, "unreviewed", unreviewed.document.title)
Ejemplo n.º 22
0
    def test_by_product(self):
        """Test the product filtering of the overview."""
        p = product(title="Firefox", slug="firefox", save=True)
        t = translated_revision(is_approved=True, save=True)

        eq_(0, l10n_overview_rows("de", product=p)["all"]["numerator"])
        eq_(0, l10n_overview_rows("de", product=p)["all"]["denominator"])

        t.document.parent.products.add(p)

        eq_(1, l10n_overview_rows("de", product=p)["all"]["numerator"])
        eq_(1, l10n_overview_rows("de", product=p)["all"]["denominator"])
Ejemplo n.º 23
0
    def test_by_product(self):
        """Test the product filtering of the overview."""
        p = product(title='Firefox', slug='firefox', save=True)
        t = translated_revision(is_approved=True, save=True)

        eq_(0, overview_rows('de', product=p)['all']['numerator'])
        eq_(0, overview_rows('de', product=p)['all']['denominator'])

        t.document.parent.products.add(p)

        eq_(1, overview_rows('de', product=p)['all']['numerator'])
        eq_(1, overview_rows('de', product=p)['all']['denominator'])
Ejemplo n.º 24
0
    def test_by_product(self):
        """Test the product filtering of the readout."""
        p = product(title="Firefox", slug="firefox", save=True)
        r = translated_revision(is_approved=True, save=True)
        d = r.document

        # There shouldn't be any rows yet.
        eq_(0, len(self.rows(product=p)))

        # Add the product to the parent document, and verify it shows up.
        d.parent.products.add(p)
        eq_(self.row(product=p)["title"], d.title)
Ejemplo n.º 25
0
    def test_render(self):
        """Assert main dash and all the readouts render and don't crash."""
        # Put some stuff in the DB so at least one row renders for each
        # readout:
        untranslated = revision(is_approved=True,
                                is_ready_for_localization=True)
        untranslated.save()

        unreviewed = translated_revision(is_ready_for_localization=True)
        unreviewed.save()

        out_of_date = translated_revision(is_approved=True,
                                          is_ready_for_localization=True)
        out_of_date.save()
        major_update = revision(document=out_of_date.document.parent,
                                significance=MAJOR_SIGNIFICANCE,
                                is_approved=True,
                                is_ready_for_localization=True)
        major_update.save()

        needing_updates = translated_revision(is_approved=True,
                                              is_ready_for_localization=True)
        needing_updates.save()
        medium_update = revision(document=needing_updates.document.parent,
                                 significance=MEDIUM_SIGNIFICANCE,
                                 is_ready_for_localization=True)
        medium_update.save()

        response = self.client.get(reverse('dashboards.localization',
                                           locale='de'),
                                   follow=False)
        eq_(200, response.status_code)
        doc = pq(response.content)
        self._assert_readout_contains(doc, 'untranslated',
                                      untranslated.document.title)
        self._assert_readout_contains(doc, 'unreviewed',
                                      unreviewed.document.title)
        self._assert_readout_contains(doc, 'out-of-date',
                                      out_of_date.document.title)
Ejemplo n.º 26
0
    def test_render(self):
        """Assert main dash and all the readouts render and don't crash."""
        # Put some stuff in the DB so at least one row renders for each
        # readout:
        untranslated = revision(is_approved=True,
                                is_ready_for_localization=True)
        untranslated.save()

        unreviewed = translated_revision(is_ready_for_localization=True)
        unreviewed.save()

        out_of_date = translated_revision(is_approved=True,
                                          is_ready_for_localization=True)
        out_of_date.save()
        major_update = revision(document=out_of_date.document.parent,
                                significance=MAJOR_SIGNIFICANCE,
                                is_approved=True,
                                is_ready_for_localization=True)
        major_update.save()

        needing_updates = translated_revision(is_approved=True,
                                              is_ready_for_localization=True)
        needing_updates.save()
        medium_update = revision(document=needing_updates.document.parent,
                                 significance=MEDIUM_SIGNIFICANCE,
                                 is_ready_for_localization=True)
        medium_update.save()

        response = self.client.get(reverse('dashboards.localization',
                                           locale='de'),
                                   follow=False)
        eq_(200, response.status_code)
        doc = pq(response.content)
        self._assert_readout_contains(doc, 'untranslated',
                                      untranslated.document.title)
        self._assert_readout_contains(doc, 'unreviewed',
                                      unreviewed.document.title)
        self._assert_readout_contains(doc, 'out-of-date',
                                      out_of_date.document.title)
Ejemplo n.º 27
0
    def test_not_navigation(self):
        """Documents not in navigation shouldn't show up in the list."""
        t = translated_revision(is_approved=False, save=True)
        t.document.category = 10
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 20
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 30
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 40
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 60
        t.document.save()

        self.assertRaises(IndexError, self.row)
Ejemplo n.º 28
0
    def test_not_navigation(self):
        """Documents not in navigation shouldn't show up in the list."""
        t = translated_revision(is_approved=False, save=True)
        t.document.category = 10
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 20
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 30
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 40
        t.document.save()

        t = translated_revision(is_approved=False, save=True)
        t.document.category = 60
        t.document.save()

        self.assertRaises(IndexError, self.row)
Ejemplo n.º 29
0
    def test_not_counting_how_to_contribute(self):
        """Articles with the How to contribute category should not be counted.
        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])

        # Update the parent with the How To Contribute category
        d = t.document.parent
        d.category = HOW_TO_CONTRIBUTE_CATEGORY
        d.save()

        overview = overview_rows('de')
        eq_(0, overview['most-visited']['numerator'])
Ejemplo n.º 30
0
    def test_render(self):
        """Assert main dash and all the readouts render and don't crash."""
        # Put some stuff in the DB so at least one row renders for each
        # readout:
        unreviewed = translated_revision(is_ready_for_localization=True)
        unreviewed.save()

        response = self.client.get(reverse('dashboards.localization',
                                           locale='de'),
                                   follow=False)
        eq_(200, response.status_code)
        doc = pq(response.content)
        self._assert_readout_contains(doc, 'unreviewed',
                                      unreviewed.document.title)
Ejemplo n.º 31
0
    def test_not_counting_how_to_contribute(self):
        """Articles with the How to contribute category should not be counted.
        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])

        # Update the parent with the How To Contribute category
        d = t.document.parent
        d.category = HOW_TO_CONTRIBUTE_CATEGORY
        d.save()

        overview = overview_rows('de')
        eq_(0, overview['most-visited']['numerator'])
Ejemplo n.º 32
0
    def test_templates_and_docs_disjunct(self):
        """Make sure templates aren't included in the All Articles count."""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        t.document.parent.title = t.document.title = 'Template:thing'
        t.document.parent.is_template = t.document.is_template = True
        t.document.parent.save()
        t.document.save()
        # ...but not when it's a template:
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Ejemplo n.º 33
0
    def _test_significance(self, significance, status):
        """
        Assert that a translation out of date due to a
        `significance`-level update to the original article shows
        status `status`.

        """
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=significance,
                 save=True)
        row = self.row()
        eq_(row['title'], translation.document.title)
        eq_(row['status'], status)
Ejemplo n.º 34
0
    def test_templates_and_docs_disjunct(self):
        """Make sure templates aren't included in the All Articles count."""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, l10n_overview_rows('de')['all']['numerator'])
        eq_(1, l10n_overview_rows('de')['all']['denominator'])

        t.document.parent.title = t.document.title = 'Template:thing'
        t.document.parent.category = TEMPLATES_CATEGORY
        # is_template will be automatically set for both templates, and so will
        # the child document's category.
        t.document.parent.save()
        t.document.save()
        # ...but not when it's a template:
        eq_(0, l10n_overview_rows('de')['all']['numerator'])
        eq_(0, l10n_overview_rows('de')['all']['denominator'])
Ejemplo n.º 35
0
    def test_templates_and_docs_disjunct(self):
        """Make sure templates aren't included in the All Articles count."""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, l10n_overview_rows('de')['all']['numerator'])
        eq_(1, l10n_overview_rows('de')['all']['denominator'])

        t.document.parent.title = t.document.title = 'Template:thing'
        t.document.parent.category = TEMPLATES_CATEGORY
        # is_template will be automatically set for both templates, and so will
        # the child document's category.
        t.document.parent.save()
        t.document.save()
        # ...but not when it's a template:
        eq_(0, l10n_overview_rows('de')['all']['numerator'])
        eq_(0, l10n_overview_rows('de')['all']['denominator'])
Ejemplo n.º 36
0
 def test_consider_only_approved_significances(self):
     """Consider only approved significances when computing the max."""
     translation = translated_revision(is_approved=True, save=True)
     revision(document=translation.document.parent,
              is_approved=False,  # shouldn't count
              is_ready_for_localization=False,
              significance=MAJOR_SIGNIFICANCE,
              save=True)
     revision(document=translation.document.parent,
              is_approved=True,
              is_ready_for_localization=True,
              significance=MEDIUM_SIGNIFICANCE,
              save=True)
     row = self.row()
     eq_(row['title'], translation.document.title)
     # This should show as medium significance, because the revision with
     # major significance is unapproved:
     eq_(unicode(row['status']), 'Update Needed')
Ejemplo n.º 37
0
    def test_consider_max_significance(self):
        """Use max significance of approved revs for changed significance

        When determining how significantly an article has changed
        since translation, use the max significance of the approved
        revisions, not just that of the latest ready-to-localize one.
        """
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=False,  # should still count
                 significance=MAJOR_SIGNIFICANCE,
                 save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE,
                 save=True)
        eq_([translation.document.title], self.titles())
Ejemplo n.º 38
0
    def test_consider_max_significance(self):
        """Use max significance of approved revs for changed significance

        When determining how significantly an article has changed
        since translation, use the max significance of the approved
        revisions, not just that of the latest ready-to-localize one.
        """
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=False,  # should still count
                 significance=MAJOR_SIGNIFICANCE,
                 save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE,
                 save=True)
        eq_([translation.document.title], self.titles())
Ejemplo n.º 39
0
    def test_not_counting_how_to_contribute(self):
        """Articles with the How to contribute category should not be counted.
        """
        t = translated_revision(is_approved=True, save=True)
        overview = l10n_overview_rows("de")
        eq_(1, overview["all"]["numerator"])
        eq_(1, overview["top-20"]["numerator"])
        eq_(1, overview["top-50"]["numerator"])
        eq_(1, overview["top-100"]["numerator"])

        # Update the parent with the How To Contribute category
        d = t.document.parent
        d.category = HOW_TO_CONTRIBUTE_CATEGORY
        d.save()

        overview = l10n_overview_rows("de")
        eq_(0, overview["all"]["numerator"])
        eq_(0, overview["top-20"]["numerator"])
        eq_(0, overview["top-50"]["numerator"])
        eq_(0, overview["top-100"]["numerator"])
Ejemplo n.º 40
0
    def test_not_fired(self):
        """Test that the Not Localized and Not Updated events don't fire
        when they are not appropriate."""
        trans = translated_revision(is_approved=True, save=True)
        trans_doc = trans.document

        # Add a parent revision of TYPO significance. This shouldn't do
        # anything, since it isn't significant enough.
        revision(document=trans.document.parent, is_approved=True,
                 is_ready_for_localization=True,
                 significance=TYPO_SIGNIFICANCE, save=True)

        url = reverse('wiki.document', args=[trans_doc.slug],
                      locale=trans_doc.locale)
        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        doc = pq(response.content)
        assert '"Not Localized"' not in doc('body').attr('data-ga-push')
        assert '"Not Updated"' not in doc('body').attr('data-ga-push')
Ejemplo n.º 41
0
    def test_custom_event_medium_out_of_date(self):
        """If a document's parent has medium edits and the document has
        not been updated, it should fire a "Not Updated" GA event."""

        # Make a document, and a translation of it.
        trans = translated_revision(is_approved=True, save=True)

        # Add a parent revision of MEDIUM significance:
        revision(document=trans.document.parent, is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE, save=True)

        url = reverse('wiki.document', args=[trans.document.slug],
                      locale=trans.document.locale)
        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        doc = pq(response.content)
        assert '"Not Localized"' not in doc('body').attr('data-ga-push')
        assert '"Not Updated"' in doc('body').attr('data-ga-push')
Ejemplo n.º 42
0
    def test_custom_event_medium_out_of_date(self):
        """If a document's parent has medium edits and the document has
        not been updated, it should fire a "Not Updated" GA event."""

        # Make a document, and a translation of it.
        trans = translated_revision(is_approved=True, save=True)

        # Add a parent revision of MEDIUM significance:
        revision(document=trans.document.parent, is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE, save=True)

        url = reverse('wiki.document', args=[trans.document.slug],
                      locale=trans.document.locale)
        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        doc = pq(response.content)
        assert '"Not Localized"' not in doc('body').attr('data-ga-push')
        assert '"Not Updated"' in doc('body').attr('data-ga-push')
Ejemplo n.º 43
0
    def test_not_fired(self):
        """Test that the Not Localized and Not Updated events don't fire
        when they are not appropriate."""
        trans = translated_revision(is_approved=True, save=True)
        trans_doc = trans.document

        # Add a parent revision of TYPO significance. This shouldn't do
        # anything, since it isn't significant enough.
        revision(document=trans.document.parent, is_approved=True,
                 is_ready_for_localization=True,
                 significance=TYPO_SIGNIFICANCE, save=True)

        url = reverse('wiki.document', args=[trans_doc.slug],
                      locale=trans_doc.locale)
        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)

        doc = pq(response.content)
        assert '"Not Localized"' not in doc('body').attr('data-ga-push')
        assert '"Not Updated"' not in doc('body').attr('data-ga-push')
Ejemplo n.º 44
0
    def test_consider_max_significance(self):
        """Use max significance for determining change significance

        When determining how significantly an article has changed
        since translation, use the max significance of the approved
        revisions, not just that of the latest ready-to-localize one.
        """
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=False,  # should still count
                 significance=MAJOR_SIGNIFICANCE,
                 save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE,
                 save=True)
        row = self.row()
        eq_(row['title'], translation.document.title)
        eq_(unicode(row['status']), 'Immediate Update Needed')
Ejemplo n.º 45
0
    def test_by_product(self):
        """Test the product filtering of the readout."""
        p = product(title='Firefox', slug='firefox', save=True)
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=False,  # should still count
                 significance=MAJOR_SIGNIFICANCE,
                 save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE,
                 save=True)

        # There shouldn't be any rows yet.
        eq_(0, len(self.rows(product=p)))

        # Add the product to the document, and verify it shows up.
        translation.document.parent.products.add(p)
        eq_(self.row(product=p)['title'], translation.document.title)
Ejemplo n.º 46
0
    def test_by_product(self):
        """Test the product filtering of the readout."""
        p = product(title='Firefox', slug='firefox', save=True)
        translation = translated_revision(is_approved=True, save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=False,  # should still count
                 significance=MAJOR_SIGNIFICANCE,
                 save=True)
        revision(document=translation.document.parent,
                 is_approved=True,
                 is_ready_for_localization=True,
                 significance=MEDIUM_SIGNIFICANCE,
                 save=True)

        # There shouldn't be any rows yet.
        eq_(0, len(self.rows(product=p)))

        # Add the product to the document, and verify it shows up.
        translation.document.parent.products.add(p)
        eq_(self.row(product=p)['title'], translation.document.title)
Ejemplo n.º 47
0
    def test_not_counting_templates(self):
        """Articles in the Templates category should not be counted.
        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['all']['numerator'])
        eq_(1, overview['top-20']['numerator'])
        eq_(1, overview['top-50']['numerator'])
        eq_(1, overview['top-100']['numerator'])

        # Update the parent and translation to be a template
        d = t.document.parent
        d.title = 'Template:Lorem Ipsum Dolor'
        d.save()
        t.document.title = 'Template:Lorem Ipsum Dolor'
        t.document.save()

        overview = overview_rows('de')
        eq_(0, overview['all']['numerator'])
        eq_(0, overview['top-20']['numerator'])
        eq_(0, overview['top-50']['numerator'])
        eq_(0, overview['top-100']['numerator'])
Ejemplo n.º 48
0
    def test_majorly_outdated(self):
        """Test the is_majorly_outdated method."""
        trans = translated_revision(is_approved=True)
        trans.save()
        trans_doc = trans.document

        # Make sure a doc returns False if it has no parent:
        assert not trans_doc.parent.is_majorly_outdated()

        assert not trans_doc.is_majorly_outdated()

        # Add a parent revision of MAJOR significance:
        r = revision(document=trans_doc.parent,
                     significance=MAJOR_SIGNIFICANCE)
        r.save()
        assert not trans_doc.is_majorly_outdated()

        # Approve it:
        r.is_approved = True
        r.is_ready_for_localization = True
        r.save()

        assert trans_doc.is_majorly_outdated()
Ejemplo n.º 49
0
 def test_current_revision_null(self):
     """Show all unreviewed revisions if none have been approved yet."""
     unreviewed = translated_revision(save=True)
     assert unreviewed.document.title in self.titles()
Ejemplo n.º 50
0
 def test_not_template(self):
     """Documents that are not templates shouldn't show up in the list.
     """
     translated_revision(is_approved=False, save=True)
     self.assertRaises(IndexError, self.row)
Ejemplo n.º 51
0
 def test_rejected_newer_than_current(self):
     """Don't show reviewed but unapproved revs newer than current rev"""
     rejected = translated_revision(reviewed=datetime.now(), save=True)
     assert rejected.document.title not in self.titles()
Ejemplo n.º 52
0
 def test_unreviewed(self):
     """Assert articles in need of review are labeled as such."""
     unreviewed = translated_revision(is_approved=False, save=True)
     row = self.row()
     eq_(row['title'], unreviewed.document.title)
     eq_(row['status'], 'Review Needed')