def test_translation_state(self): eng_doc = DocumentFactory(category=CANNED_RESPONSES_CATEGORY) eng_rev = ApprovedRevisionFactory(is_ready_for_localization=True, document=eng_doc) eq_("untranslated", self.row()["status_class"]) # Now translate it, but don't approve de_doc = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, parent=eng_doc, locale="de") de_rev = RevisionFactory(document=de_doc, based_on=eng_rev, is_approved=False, reviewed=None) eq_("review", self.row()["status_class"]) # Approve it, so now every this is ok. de_rev.is_approved = True de_rev.save() eq_("ok", self.row()["status_class"]) # Now update the parent, so it becomes minorly out of date ApprovedRevisionFactory(is_ready_for_localization=True, document=eng_doc, significance=MEDIUM_SIGNIFICANCE) eq_("update", self.row()["status_class"]) # Now update the parent, so it becomes majorly out of date ApprovedRevisionFactory(is_ready_for_localization=True, document=eng_doc, significance=MAJOR_SIGNIFICANCE) eq_("out-of-date", self.row()["status_class"])
def test_majorly_outdated(self): """Test the is_majorly_outdated method.""" trans = TranslatedRevisionFactory(is_approved=True) 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 = RevisionFactory(document=trans_doc.parent, significance=MAJOR_SIGNIFICANCE) 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()
def test_ready_for_l10n_updates_doc(self): """Approving and marking ready a rev should update the doc's ref.""" # Ready a rev in a new doc: ready_1 = ApprovedRevisionFactory(is_ready_for_localization=True) eq_(ready_1, ready_1.document.latest_localizable_revision) # Add an unready revision that we can ready later: unready = RevisionFactory(document=ready_1.document, is_approved=False, is_ready_for_localization=False) # Ready a rev in a doc that already has a ready revision: ready_2 = ApprovedRevisionFactory(document=ready_1.document, is_ready_for_localization=True) eq_(ready_2, ready_2.document.latest_localizable_revision) # Ready the older rev. It should not become the latest_localizable. unready.is_ready_for_localization = True unready.is_approved = True unready.save() eq_(ready_2, ready_2.document.latest_localizable_revision)
def test_ready_for_l10n_updates_doc(self): """Approving and marking ready a rev should update the doc's ref.""" # Ready a rev in a new doc: ready_1 = ApprovedRevisionFactory(is_ready_for_localization=True) eq_(ready_1, ready_1.document.latest_localizable_revision) # Add an unready revision that we can ready later: unready = RevisionFactory( document=ready_1.document, is_approved=False, is_ready_for_localization=False) # Ready a rev in a doc that already has a ready revision: ready_2 = ApprovedRevisionFactory( document=ready_1.document, is_ready_for_localization=True) eq_(ready_2, ready_2.document.latest_localizable_revision) # Ready the older rev. It should not become the latest_localizable. unready.is_ready_for_localization = True unready.is_approved = True unready.save() eq_(ready_2, ready_2.document.latest_localizable_revision)
def test_translation_state(self): eng_doc = DocumentFactory(category=CANNED_RESPONSES_CATEGORY) eng_rev = ApprovedRevisionFactory(is_ready_for_localization=True, document=eng_doc) eq_('untranslated', self.row()['status_class']) # Now translate it, but don't approve de_doc = DocumentFactory(category=CANNED_RESPONSES_CATEGORY, parent=eng_doc, locale='de') de_rev = RevisionFactory( document=de_doc, based_on=eng_rev, is_approved=False, reviewed=None) eq_('review', self.row()['status_class']) # Approve it, so now every this is ok. de_rev.is_approved = True de_rev.save() eq_('ok', self.row()['status_class']) # Now update the parent, so it becomes minorly out of date ApprovedRevisionFactory( is_ready_for_localization=True, document=eng_doc, significance=MEDIUM_SIGNIFICANCE) eq_('update', self.row()['status_class']) # Now update the parent, so it becomes majorly out of date ApprovedRevisionFactory( is_ready_for_localization=True, document=eng_doc, significance=MAJOR_SIGNIFICANCE) eq_('out-of-date', self.row()['status_class'])
def test_revision_save(self): revision = RevisionFactory(document=self.document, keywords="foobar") revision.is_approved = True revision.save() self.assertIn("foobar", self.get_doc().keywords["en-US"])