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


Python SourceVersion.persist_changes方法代码示例

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


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

示例1: test_persist_changes_positive__seed_from_previous_over_parent

# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import persist_changes [as 别名]
    def test_persist_changes_positive__seed_from_previous_over_parent(self):
        version1 = SourceVersion.for_base_object(self.source1, 'version1')
        version1.concepts = [1]
        version1.full_clean()
        version1.save()

        version2 = SourceVersion.for_base_object(self.source1, 'version2')
        version2.concepts = [2]
        version2.full_clean()
        version2.save()
        self.assertIsNone(version2.previous_version)

        version3 = SourceVersion.for_base_object(self.source1, 'version3')
        version3.full_clean()
        version3.save()

        mnemonic = version3.mnemonic
        released = version3.released
        description = version3.description
        external_id = version3.external_id

        id = version3.id
        version3._parent_version_mnemonic = 'version2'
        version3._previous_version_mnemonic = 'version1'
        version3.mnemonic = "%s-prime" % mnemonic
        version3.released = not released
        version3.description = "%s-prime" % description
        version3.external_id = "%s-prime" % external_id

        errors = SourceVersion.persist_changes(version3)
        self.assertEquals(0, len(errors))

        version3 = SourceVersion.objects.get(id=id)
        self.assertEquals(self.source1, version3.versioned_object)
        self.assertEquals(3, self.source1.num_versions)
        self.assertEquals(version3, SourceVersion.get_latest_version_of(self.source1))
        self.assertEquals(version1, version3.previous_version)
        self.assertEquals(version2, version3.parent_version)
        self.assertEquals([], version3.concepts)
        self.assertNotEquals(mnemonic, version3.mnemonic)
        self.assertNotEquals(released, version3.released)
        self.assertNotEquals(description, version3.description)
        self.assertNotEquals(external_id, version3.external_id)

        errors = SourceVersion.persist_changes(version3, seed_concepts=True)
        self.assertEquals(0, len(errors))

        version3 = SourceVersion.objects.get(id=id)
        self.assertEquals(self.source1, version3.versioned_object)
        self.assertEquals(3, self.source1.num_versions)
        self.assertEquals(version3, SourceVersion.get_latest_version_of(self.source1))
        self.assertEquals(version2, version3.parent_version)
        self.assertEquals(version1, version3.previous_version)
        self.assertEquals([1], version3.concepts)
开发者ID:rkorytkowski,项目名称:oclapi,代码行数:56,代码来源:tests.py

示例2: test_persist_changes_positive__good_parent_version

# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import persist_changes [as 别名]
    def test_persist_changes_positive__good_parent_version(self):
        version1 = SourceVersion.for_base_object(self.source1, 'version1')
        version1.full_clean()
        version1.save()

        version2 = SourceVersion.for_base_object(self.source1, 'version2')
        version2.full_clean()
        version2.save()
        self.assertIsNone(version2.parent_version)

        mnemonic = version2.mnemonic
        released = version2.released
        description = version2.description
        external_id = version2.external_id

        id = version2.id
        version2._parent_version_mnemonic = 'version1'
        version2.mnemonic = "%s-prime" % mnemonic
        version2.released = not released
        version2.description = "%s-prime" % description
        version2.external_id = "%s-prime" % external_id

        errors = SourceVersion.persist_changes(version2)
        self.assertEquals(0, len(errors))

        version2 = SourceVersion.objects.get(id=id)
        self.assertEquals(self.source1, version2.versioned_object)
        self.assertEquals(2, self.source1.num_versions)
        self.assertEquals(version2, SourceVersion.get_latest_version_of(self.source1))
        self.assertEquals(version1, version2.parent_version)
        self.assertNotEquals(mnemonic, version2.mnemonic)
        self.assertNotEquals(released, version2.released)
        self.assertNotEquals(description, version2.description)
        self.assertNotEquals(external_id, version2.external_id)
开发者ID:rkorytkowski,项目名称:oclapi,代码行数:36,代码来源:tests.py

示例3: test_persist_changes_negative__parent_version_is_self

# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import persist_changes [as 别名]
    def test_persist_changes_negative__parent_version_is_self(self):
        version1 = SourceVersion.for_base_object(self.source1, 'version1', released=True)
        version1.full_clean()
        version1.save()

        mnemonic = version1.mnemonic
        released = version1.released
        description = version1.description
        external_id = version1.external_id

        id = version1.id
        version1._parent_version_mnemonic = mnemonic
        version1.released = not released
        version1.description = "%s-prime" % description
        version1.external_id = "%s-prime" % external_id

        errors = SourceVersion.persist_changes(version1)
        self.assertEquals(1, len(errors))
        self.assertTrue('parentVersion' in errors)

        version1 = SourceVersion.objects.get(id=id)
        self.assertEquals(self.source1, version1.versioned_object)
        self.assertEquals(1, self.source1.num_versions)
        self.assertEquals(version1, SourceVersion.get_latest_version_of(self.source1))
        self.assertEquals(mnemonic, version1.mnemonic)
        self.assertEquals(released, version1.released)
        self.assertEquals(description, version1.description)
        self.assertEquals(external_id, version1.external_id)
开发者ID:rkorytkowski,项目名称:oclapi,代码行数:30,代码来源:tests.py

示例4: save_object

# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import persist_changes [as 别名]
 def save_object(self, obj, **kwargs):
     errors = SourceVersion.persist_changes(obj, **kwargs)
     self._errors.update(errors)
开发者ID:AnshuAg,项目名称:oclapi,代码行数:5,代码来源:serializers.py


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