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


Python EntityFactory.create方法代码示例

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


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

示例1: create_db_entities_translations

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
 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,代码行数:28,代码来源:test_sync_projects.py

示例2: setUp

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
 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,代码行数:28,代码来源:test_models.py

示例3: test_locales_parts_stats_pages_tied_to_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:34,代码来源:test_models.py

示例4: test_parts_stats_pages_tied_to_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:33,代码来源:test_models.py

示例5: test_for_project_locale_order

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:12,代码来源:test_models.py

示例6: setUp

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
 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,代码行数:13,代码来源:test_models.py

示例7: test_for_project_locale_filter

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
 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,代码行数:16,代码来源:test_models.py

示例8: setUp

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
 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,代码行数:50,代码来源:test_models.py

示例9: test_parts_stats_no_page_multiple_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:21,代码来源:test_models.py

示例10: test_parts_stats_pages_tied_to_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:22,代码来源:test_models.py

示例11: test_for_project_locale_order

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:22,代码来源:test_models.py

示例12: test_parts_stats_no_page_multiple_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:24,代码来源:test_models.py

示例13: setUp

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    def setUp(self):
        super(TranslationUpdateTestCase, self).setUp()

        locale = LocaleFactory.create()
        project = ProjectFactory.create()
        ProjectLocale.objects.create(
            project=project,
            locale=locale,
        )
        resource = ResourceFactory.create(project=project)
        entity = EntityFactory.create(resource=resource)

        self.translation = TranslationFactory.create(entity=entity, locale=locale)
        self.translation.locale.translators_group.user_set.add(self.user)
开发者ID:MikkCZ,项目名称:pontoon,代码行数:16,代码来源:test_views.py

示例14: test_locales_parts_stats_no_page_multiple_resources

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    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,代码行数:25,代码来源:test_models.py

示例15: setUp

# 需要导入模块: from pontoon.base.tests import EntityFactory [as 别名]
# 或者: from pontoon.base.tests.EntityFactory import create [as 别名]
    def setUp(self):
        timezone_patch = patch('pontoon.sync.core.timezone')
        self.mock_timezone = timezone_patch.start()
        self.addCleanup(timezone_patch.stop)
        self.mock_timezone.now.return_value = aware_datetime(1970, 1, 1)

        self.translated_locale = LocaleFactory.create(code='translated-locale')
        self.inactive_locale = LocaleFactory.create(code='inactive-locale')
        self.repository = RepositoryFactory()

        self.db_project = ProjectFactory.create(
            name='db-project',
            locales=[self.translated_locale],
            repositories=[self.repository]
        )
        self.main_db_resource = ResourceFactory.create(
            project=self.db_project,
            path='main.lang',
            format='lang'
        )
        self.other_db_resource = ResourceFactory.create(
            project=self.db_project,
            path='other.lang',
            format='lang'
        )
        self.missing_db_resource = ResourceFactory.create(
            project=self.db_project,
            path='missing.lang',
            format='lang'
        )
        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': []}
        )

        # Load paths from the fake locale directory.
        checkout_path_patch = patch.object(
            Project,
            'checkout_path',
            new_callable=PropertyMock,
            return_value=FAKE_CHECKOUT_PATH
        )
        checkout_path_patch.start()
        self.addCleanup(checkout_path_patch.stop)

        self.vcs_project = VCSProject(self.db_project)
        self.main_vcs_resource = self.vcs_project.resources[self.main_db_resource.path]
        self.other_vcs_resource = self.vcs_project.resources[self.other_db_resource.path]
        self.missing_vcs_resource = self.vcs_project.resources[self.missing_db_resource.path]
        self.main_vcs_entity = self.main_vcs_resource.entities['Source String']
        self.main_vcs_translation = self.main_vcs_entity.translations['translated-locale']

        # Mock VCSResource.save() for each resource to avoid altering
        # the filesystem.
        resource_save_patch = patch.object(VCSResource, 'save')
        resource_save_patch.start()
        self.addCleanup(resource_save_patch.stop)

        self.changeset = ChangeSet(
            self.db_project,
            self.vcs_project,
            aware_datetime(1970, 1, 1)
        )
开发者ID:rajul,项目名称:pontoon,代码行数:82,代码来源:__init__.py


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