Exemple #1
0
    def test_parts_stats_pages_tied_to_resources(self):
        """
        Return subpage name and stats for locales resources are available for.
        """
        resource_other = ResourceFactory.create(project=self.project,
                                                path='/other/path.po')
        EntityFactory.create(resource=resource_other)
        TranslatedResourceFactory.create(resource=resource_other,
                                         locale=self.locale)
        TranslatedResourceFactory.create(resource=resource_other,
                                         locale=self.locale_other)
        SubpageFactory.create(project=self.project,
                              name='Subpage',
                              resources=[self.resource])
        SubpageFactory.create(project=self.project,
                              name='Other Subpage',
                              resources=[resource_other])

        details = self.locale.parts_stats(self.project)
        details_other = self.locale_other.parts_stats(self.project)

        assert_equal(details[0]['title'], 'Other Subpage')
        assert_equal(details[0]['translated_strings'], 0)
        assert_equal(details[1]['title'], 'Subpage')
        assert_equal(details[1]['translated_strings'], 0)
        assert_equal(details_other[0]['title'], 'Other Subpage')
        assert_equal(details_other[0]['translated_strings'], 0)
Exemple #2
0
    def test_locales_parts_stats_pages_tied_to_resources(self):
        """
        Return subpage name and stats for locales resources are available for.
        """
        resource_other = ResourceFactory.create(project=self.project,
                                                path='/other/path.po')
        EntityFactory.create(resource=resource_other)
        StatsFactory.create(resource=resource_other, locale=self.locale)
        StatsFactory.create(resource=resource_other, locale=self.locale_other)
        SubpageFactory.create(project=self.project,
                              name='Subpage',
                              resources=[self.resource])
        SubpageFactory.create(project=self.project,
                              name='Other Subpage',
                              resources=[resource_other])

        project_details = self._fetch_locales_parts_stats()
        details = project_details.get(self.locale.code)
        details_other = project_details.get(self.locale_other.code)

        assert_equal(details[0]['resource__path'], 'Other Subpage')
        assert_equal(details[0]['translated_count'], 0)
        assert_equal(details[1]['resource__path'], 'Subpage')
        assert_equal(details[1]['translated_count'], 0)
        assert_equal(details_other[0]['resource__path'], 'Other Subpage')
        assert_equal(details_other[0]['translated_count'], 0)
Exemple #3
0
    def test_locales_parts_stats_pages_tied_to_resources(self):
        """
        Return subpage name and stats for locales resources are available for.
        """
        resource_other = ResourceFactory.create(
            project=self.project,
            path='/other/path.po'
        )
        EntityFactory.create(resource=resource_other)
        StatsFactory.create(resource=resource_other, locale=self.locale)
        StatsFactory.create(resource=resource_other, locale=self.locale_other)
        SubpageFactory.create(
            project=self.project,
            name='Subpage',
            resources=[self.resource]
        )
        SubpageFactory.create(
            project=self.project,
            name='Other Subpage',
            resources=[resource_other]
        )

        project_details = self._fetch_locales_parts_stats()
        details = project_details.get(self.locale.code)
        details_other = project_details.get(self.locale_other.code)

        assert_equal(details[0]['resource__path'], 'Other Subpage')
        assert_equal(details[0]['translated_count'], 0)
        assert_equal(details[1]['resource__path'], 'Subpage')
        assert_equal(details[1]['translated_count'], 0)
        assert_equal(details_other[0]['resource__path'], 'Other Subpage')
        assert_equal(details_other[0]['translated_count'], 0)
Exemple #4
0
    def test_parts_stats_pages_tied_to_resources(self):
        """
        Return subpage name and stats for locales resources are available for.
        """
        resource_other = ResourceFactory.create(
            project=self.project,
            path='/other/path.po'
        )
        EntityFactory.create(resource=resource_other)
        TranslatedResourceFactory.create(resource=resource_other, locale=self.locale)
        TranslatedResourceFactory.create(resource=resource_other, locale=self.locale_other)
        SubpageFactory.create(
            project=self.project,
            name='Subpage',
            resources=[self.resource]
        )
        SubpageFactory.create(
            project=self.project,
            name='Other Subpage',
            resources=[resource_other]
        )

        details = self.locale.parts_stats(self.project)
        details_other = self.locale_other.parts_stats(self.project)

        assert_equal(details[0]['title'], 'Other Subpage')
        assert_equal(details[0]['translated_strings'], 0)
        assert_equal(details[1]['title'], 'Subpage')
        assert_equal(details[1]['translated_strings'], 0)
        assert_equal(details_other[0]['title'], 'Other Subpage')
        assert_equal(details_other[0]['translated_strings'], 0)
Exemple #5
0
    def test_parts_stats_pages_not_tied_to_resources(self):
        """
        Return subpage name and stats.
        """
        SubpageFactory.create(project=self.project, name="Subpage")

        details = self.locale.parts_stats(self.project)

        assert_equal(details[0]["resource__path"], "Subpage")
        assert_equal(details[0]["translated_count"], 0)
Exemple #6
0
    def test_parts_stats_pages_not_tied_to_resources(self):
        """
        Return subpage name and stats.
        """
        SubpageFactory.create(project=self.project, name='Subpage')

        details = self.locale.parts_stats(self.project)

        assert_equal(details[0]['resource__path'], 'Subpage')
        assert_equal(details[0]['translated_count'], 0)
Exemple #7
0
    def test_parts_stats_pages_not_tied_to_resources(self):
        """
        Return subpage name and stats.
        """
        SubpageFactory.create(project=self.project, name='Subpage')

        details = self.locale.parts_stats(self.project)

        assert_equal(details[0]['title'], 'Subpage')
        assert_equal(details[0]['translated_strings'], 0)
Exemple #8
0
    def test_locales_parts_stats_pages_not_tied_to_resources(self):
        """
        Return subpage name and stats.
        """
        SubpageFactory.create(project=self.project, name='Subpage')

        project_details = self._fetch_locales_parts_stats()
        details = project_details.get(self.locale.code)

        assert_equal(details[0]['resource__path'], 'Subpage')
        assert_equal(details[0]['translated_count'], 0)
Exemple #9
0
 def setUp(self):
     self.locale = LocaleFactory.create(cldr_plurals="0,1")
     self.project = ProjectFactory.create(locales=[self.locale])
     self.main_resource = ResourceFactory.create(project=self.project,
                                                 path='main.lang')
     self.other_resource = ResourceFactory.create(project=self.project,
                                                  path='other.lang')
     self.main_entity = EntityFactory.create(
         resource=self.main_resource,
         string='Source String',
         string_plural='Plural Source String',
         key='Source String')
     self.other_entity = EntityFactory.create(resource=self.other_resource,
                                              string='Other Source String',
                                              key='Key' + KEY_SEPARATOR +
                                              'Other Source String')
     self.main_translation = TranslationFactory.create(
         entity=self.main_entity,
         locale=self.locale,
         plural_form=0,
         string='Translated String')
     self.main_translation_plural = TranslationFactory.create(
         entity=self.main_entity,
         locale=self.locale,
         plural_form=1,
         string='Translated Plural String')
     self.other_translation = TranslationFactory.create(
         entity=self.other_entity,
         locale=self.locale,
         string='Other Translated String')
     self.subpage = SubpageFactory.create(project=self.project,
                                          name='Subpage',
                                          resources=[self.main_resource])
Exemple #10
0
 def setUp(self):
     self.locale = LocaleFactory.create(cldr_plurals="0,1")
     self.project = ProjectFactory.create(locales=[self.locale])
     self.main_resource = ResourceFactory.create(project=self.project, path="main.lang")
     self.other_resource = ResourceFactory.create(project=self.project, path="other.lang")
     self.main_entity = EntityFactory.create(
         resource=self.main_resource,
         string="Source String",
         string_plural="Plural Source String",
         key="Source String",
     )
     self.other_entity = EntityFactory.create(
         resource=self.other_resource,
         string="Other Source String",
         key="Key" + KEY_SEPARATOR + "Other Source String",
     )
     self.main_translation = TranslationFactory.create(
         entity=self.main_entity, locale=self.locale, plural_form=0, string="Translated String"
     )
     self.main_translation_plural = TranslationFactory.create(
         entity=self.main_entity, locale=self.locale, plural_form=1, string="Translated Plural String"
     )
     self.other_translation = TranslationFactory.create(
         entity=self.other_entity, locale=self.locale, string="Other Translated String"
     )
     self.subpage = SubpageFactory.create(project=self.project, name="Subpage", resources=[self.main_resource])
Exemple #11
0
    def test_parts_stats_pages_tied_to_resources(self):
        """
        Return subpage name and stats for locales resources are available for.
        """
        resource_other = ResourceFactory.create(project=self.project, path="/other/path.po")
        EntityFactory.create(resource=resource_other)
        StatsFactory.create(resource=resource_other, locale=self.locale)
        StatsFactory.create(resource=resource_other, locale=self.locale_other)
        SubpageFactory.create(project=self.project, name="Subpage", resources=[self.resource])
        SubpageFactory.create(project=self.project, name="Other Subpage", resources=[resource_other])

        details = self.locale.parts_stats(self.project)
        details_other = self.locale_other.parts_stats(self.project)

        assert_equal(details[0]["resource__path"], "Other Subpage")
        assert_equal(details[0]["translated_count"], 0)
        assert_equal(details[1]["resource__path"], "Subpage")
        assert_equal(details[1]["translated_count"], 0)
        assert_equal(details_other[0]["resource__path"], "Other Subpage")
        assert_equal(details_other[0]["translated_count"], 0)
Exemple #12
0
 def setUp(self):
     self.locale = LocaleFactory.create(
         cldr_plurals="0,1"
     )
     self.project = ProjectFactory.create(
         locales=[self.locale]
     )
     self.main_resource = ResourceFactory.create(
         project=self.project,
         path='main.lang'
     )
     self.other_resource = ResourceFactory.create(
         project=self.project,
         path='other.lang'
     )
     self.main_entity = EntityFactory.create(
         resource=self.main_resource,
         string='Source String',
         string_plural='Plural Source String',
         key='Source String'
     )
     self.other_entity = EntityFactory.create(
         resource=self.other_resource,
         string='Other Source String',
         key='Key' + KEY_SEPARATOR + 'Other Source String'
     )
     self.main_translation = TranslationFactory.create(
         entity=self.main_entity,
         locale=self.locale,
         plural_form=0,
         string='Translated String'
     )
     self.main_translation_plural = TranslationFactory.create(
         entity=self.main_entity,
         locale=self.locale,
         plural_form=1,
         string='Translated Plural String'
     )
     self.other_translation = TranslationFactory.create(
         entity=self.other_entity,
         locale=self.locale,
         string='Other Translated String'
     )
     self.subpage = SubpageFactory.create(
         project=self.project,
         name='Subpage',
         resources=[self.main_resource]
     )