当前位置: 首页>>代码示例>>Python>>正文


Python tests.EntityFactory类代码示例

本文整理汇总了Python中pontoon.base.tests.EntityFactory的典型用法代码示例。如果您正苦于以下问题:Python EntityFactory类的具体用法?Python EntityFactory怎么用?Python EntityFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EntityFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 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])
开发者ID:dsaumyajit007,项目名称:pontoon,代码行数:26,代码来源:test_models.py

示例2: test_locales_parts_stats_pages_tied_to_resources

    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)
开发者ID:rajul,项目名称:pontoon,代码行数:32,代码来源:test_models.py

示例3: create_db_entities_translations

 def create_db_entities_translations(self):
     """
     Create entities and translations in the database for strings
     from the fake checkout.
     """
     self.main_db_entity = EntityFactory.create(
         resource=self.main_db_resource,
         string='Source String',
         key='Source String',
         obsolete=False
     )
     self.other_db_entity = EntityFactory.create(
         resource=self.other_db_resource,
         string='Other Source String',
         key='Other Source String',
         obsolete=False
     )
     self.main_db_translation = TranslationFactory.create(
         entity=self.main_db_entity,
         plural_form=None,
         locale=self.translated_locale,
         string='Translated String',
         date=aware_datetime(1970, 1, 1),
         approved=True,
         extra={'tags': []}
     )
开发者ID:m8ttyB,项目名称:pontoon,代码行数:26,代码来源:test_sync_projects.py

示例4: test_parts_stats_pages_tied_to_resources

    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)
开发者ID:transforlab,项目名称:pontoon,代码行数:31,代码来源:test_models.py

示例5: test_for_project_locale_order

    def test_for_project_locale_order(self):
        """
        Return entities in correct order.
        """
        entity_second = EntityFactory.create(order=1, resource=self.main_resource, string="Second String")
        entity_first = EntityFactory.create(order=0, resource=self.main_resource, string="First String")
        entities = Entity.for_project_locale(self.project, self.locale)

        assert_equal(entities[2]["original"], "First String")
        assert_equal(entities[3]["original"], "Second String")
开发者ID:riseofthetigers,项目名称:pontoon,代码行数:10,代码来源:test_models.py

示例6: setUp

 def setUp(self):
     self.locale, self.locale_other = LocaleFactory.create_batch(2)
     self.project = ProjectFactory.create(
         locales=[self.locale, self.locale_other]
     )
     self.resource = ResourceFactory.create(
         project=self.project,
         path='/main/path.po'
     )
     EntityFactory.create(resource=self.resource)
     StatsFactory.create(resource=self.resource, locale=self.locale)
开发者ID:rajul,项目名称:pontoon,代码行数:11,代码来源:test_models.py

示例7: test_for_project_locale_filter

 def test_for_project_locale_filter(self):
     """
     Evaluate entities filtering by locale, project, obsolete.
     """
     other_locale = LocaleFactory.create()
     other_project = ProjectFactory.create(locales=[self.locale, other_locale])
     # Obsolete_entity
     EntityFactory.create(obsolete=True, resource=self.main_resource, string="Obsolete String")
     entities = Entity.for_project_locale(self.project, other_locale)
     assert_equal(len(entities), 0)
     entities = Entity.for_project_locale(other_project, self.locale)
     assert_equal(len(entities), 0)
     entities = Entity.for_project_locale(self.project, self.locale)
     assert_equal(len(entities), 2)
开发者ID:dsaumyajit007,项目名称:pontoon,代码行数:14,代码来源:test_models.py

示例8: setUp

 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]
     )
开发者ID:waseem18,项目名称:pontoon,代码行数:48,代码来源:test_models.py

示例9: setUp

 def setUp(self):
     self.resource = ResourceFactory.create()
     self.locale = LocaleFactory.create()
     ProjectLocale.objects.create(project=self.resource.project, locale=self.locale)
     TranslatedResource.objects.create(resource=self.resource, locale=self.locale)
     self.entities = EntityFactory.create_batch(3, resource=self.resource)
     self.entities_pks = [e.pk for e in self.entities]
开发者ID:MikkCZ,项目名称:pontoon,代码行数:7,代码来源:test_views.py

示例10: test_parts_stats_no_page_multiple_resources

    def test_parts_stats_no_page_multiple_resources(self):
        """
        Return resource paths 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)

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

        assert_equal(details[0]["resource__path"], "/main/path.po")
        assert_equal(details[0]["translated_count"], 0)
        assert_equal(details[1]["resource__path"], "/other/path.po")
        assert_equal(details[1]["translated_count"], 0)
        assert_equal(len(details_other), 1)
        assert_equal(details_other[0]["resource__path"], "/other/path.po")
        assert_equal(details_other[0]["translated_count"], 0)
开发者ID:dsaumyajit007,项目名称:pontoon,代码行数:19,代码来源:test_models.py

示例11: test_for_project_locale_order

    def test_for_project_locale_order(self):
        """
        Return entities in correct order.
        """
        # First entity
        EntityFactory.create(
            order=1,
            resource=self.main_resource,
            string='Second String'
        )
        # Second entity
        EntityFactory.create(
            order=0,
            resource=self.main_resource,
            string='First String'
        )
        entities = Entity.for_project_locale(self.project, self.locale)

        assert_equal(entities[2]['original'], 'First String')
        assert_equal(entities[3]['original'], 'Second String')
开发者ID:rajul,项目名称:pontoon,代码行数:20,代码来源:test_models.py

示例12: test_parts_stats_pages_tied_to_resources

    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)
开发者ID:dsaumyajit007,项目名称:pontoon,代码行数:20,代码来源:test_models.py

示例13: test_parts_stats_no_page_multiple_resources

    def test_parts_stats_no_page_multiple_resources(self):
        """
        Return resource paths 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)

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

        assert_equal(details[0]['title'], '/main/path.po')
        assert_equal(details[0]['translated_strings'], 0)
        assert_equal(details[1]['title'], '/other/path.po')
        assert_equal(details[1]['translated_strings'], 0)
        assert_equal(len(details_other), 1)
        assert_equal(details_other[0]['title'], '/other/path.po')
        assert_equal(details_other[0]['translated_strings'], 0)
开发者ID:transforlab,项目名称:pontoon,代码行数:22,代码来源:test_models.py

示例14: test_locales_parts_stats_no_page_multiple_resources

    def test_locales_parts_stats_no_page_multiple_resources(self):
        """
        Return resource paths 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)

        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'], '/main/path.po')
        assert_equal(details[0]['translated_count'], 0)
        assert_equal(details[1]['resource__path'], '/other/path.po')
        assert_equal(details[1]['translated_count'], 0)
        assert_equal(len(details_other), 1)
        assert_equal(details_other[0]['resource__path'], '/other/path.po')
        assert_equal(details_other[0]['translated_count'], 0)
开发者ID:rajul,项目名称:pontoon,代码行数:23,代码来源:test_models.py

示例15: setUp

 def setUp(self):
     # Create a list of instances in order to filter them.
     EntityFactory.create_batch(10)
开发者ID:bidaian,项目名称:pontoon,代码行数:3,代码来源:test_lookups.py


注:本文中的pontoon.base.tests.EntityFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。