Esempio n. 1
0
    def test_translation_status_view(self):
        TranslationBranchFactory()
        TranslationBranchFactory()
        TranslationBranchFactory()

        url = reverse("translation_status")
        with mock.patch.object(LegalCode, "get_pofile"):
            rsp = self.client.get(url)
        self.assertTemplateUsed(rsp, "licenses/translation_status.html")
        context = rsp.context
        self.assertEqual(3, len(context["branches"]))
Esempio n. 2
0
    def test_stats(self):
        language_code = "es"
        lc1 = LegalCodeFactory(language_code=language_code)
        tb = TranslationBranchFactory(language_code=language_code,
                                      legalcodes=[lc1])

        class MockPofile(list):
            def untranslated_entries(self):
                return [1, 2, 3, 4, 5]

            def translated_entries(self):
                return [1, 2, 3]

        mock_pofile = MockPofile()
        with mock.patch.object(LegalCode, "get_pofile") as mock_get_pofile:
            mock_get_pofile.return_value = mock_pofile
            stats = tb.stats
        self.assertEqual(
            {
                "percent_messages_translated": 37,
                "number_of_total_messages": 8,
                "number_of_translated_messages": 3,
                "number_of_untranslated_messages": 5,
            },
            stats,
        )
Esempio n. 3
0
 def test_str(self):
     tc = TranslationBranchFactory(complete=False)
     expected = f"Translation branch {tc.branch_name}. In progress."
     self.assertEqual(expected, str(tc))
Esempio n. 4
0
 def setUp(self):
     self.translation_branch = TranslationBranchFactory(
         language_code="fr",
     )