本文整理汇总了Python中sources.models.SourceVersion.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python SourceVersion.full_clean方法的具体用法?Python SourceVersion.full_clean怎么用?Python SourceVersion.full_clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sources.models.SourceVersion
的用法示例。
在下文中一共展示了SourceVersion.full_clean方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_source_version_create_positive__same_mnemonic
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_source_version_create_positive__same_mnemonic(self):
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source1.id
).exists())
self.assertEquals(1, self.source1.num_versions)
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source2,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source2.id
).exists())
self.assertEquals(1, self.source2.num_versions)
示例2: test_source_version_create_negative__same_mnemonic
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_source_version_create_negative__same_mnemonic(self):
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertEquals(1, self.source1.num_versions)
with self.assertRaises(ValidationError):
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertEquals(1, self.source1.num_versions)
示例3: test_source_version_create_positive
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_source_version_create_positive(self):
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
released=True,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source1.id
).exists())
self.assertIsNone(source_version.previous_version)
self.assertIsNone(source_version.previous_version_mnemonic)
self.assertIsNone(source_version.parent_version)
self.assertIsNone(source_version.parent_version_mnemonic)
self.assertEquals(self.org1.mnemonic, source_version.parent_resource)
self.assertEquals(self.org1.resource_type, source_version.parent_resource_type)
self.assertEquals(source_version, SourceVersion.get_latest_version_of(self.source1))
self.assertEquals(1, self.source1.num_versions)
示例4: test_source_version_create_negative__no_source
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_source_version_create_negative__no_source(self):
with self.assertRaises(ValidationError):
source_version = SourceVersion(
mnemonic='version1',
name='version1',
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
self.assertEquals(0, self.source1.num_versions)
示例5: test_get_latest_version_of
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_get_latest_version_of(self):
latest_version_identity = 'version'
expected_latest_source_version = SourceVersion(
name=latest_version_identity,
mnemonic=latest_version_identity,
versioned_object=self.source,
released=True,
created_by=self.user,
updated_by=self.user,
)
expected_latest_source_version.full_clean()
expected_latest_source_version.save()
self.assertEquals(SourceVersion.get_latest_version_of(self.source).name, latest_version_identity)
示例6: test_dispatch_with_head_and_versions
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_dispatch_with_head_and_versions(self):
source_version = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
released=True,
created_by=self.user1,
updated_by=self.user1,
)
source_version.full_clean()
source_version.save()
concept2 = Concept(
mnemonic='concept2',
created_by=self.user1,
updated_by=self.user1,
parent=self.source1,
concept_class='not First',
external_id='EXTID',
names=[self.name],
)
display_name = LocalizedText(
name='concept2',
locale='en'
)
concept2.names.append(display_name)
kwargs = {
'parent_resource': self.source1,
}
Concept.persist_new(concept2, self.user1, **kwargs)
self.client.login(username='user1', password='user1')
kwargs = {
'org': self.org1.mnemonic,
'source': self.source1.mnemonic
}
response = self.client.get(reverse('concept-create', kwargs=kwargs))
self.assertEquals(response.status_code, 200)
content = json.loads(response.content)
self.assertEquals(2, len(content))
source_head_concepts = SourceVersion.objects.get(mnemonic='HEAD', versioned_object_id=self.source1.id).concepts
self.assertEquals(2, len(source_head_concepts))
for concept in content:
self.assertTrue(concept['version'] in source_head_concepts)
示例7: test_source_version_create_positive__child_and_subsequent_versions
# 需要导入模块: from sources.models import SourceVersion [as 别名]
# 或者: from sources.models.SourceVersion import full_clean [as 别名]
def test_source_version_create_positive__child_and_subsequent_versions(self):
version1 = SourceVersion(
name='version1',
mnemonic='version1',
versioned_object=self.source1,
released=True,
created_by=self.user1,
updated_by=self.user1,
)
version1.full_clean()
version1.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source1.id
).exists())
self.assertEquals(version1, SourceVersion.get_latest_version_of(self.source1))
self.assertEquals(1, self.source1.num_versions)
version2 = SourceVersion(
name='version2',
mnemonic='version2',
versioned_object=self.source1,
parent_version=version1,
created_by=self.user1,
updated_by=self.user1,
)
version2.full_clean()
version2.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version2',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source1.id
).exists())
self.assertEquals(version1, version2.parent_version)
self.assertEquals(version1.mnemonic, version2.parent_version_mnemonic)
self.assertIsNone(version2.previous_version)
self.assertIsNone(version2.previous_version_mnemonic)
self.assertEquals(2, self.source1.num_versions)
version3 = SourceVersion(
name='version3',
mnemonic='version3',
versioned_object=self.source1,
previous_version=version2,
created_by=self.user1,
updated_by=self.user1,
)
version3.full_clean()
version3.save()
self.assertTrue(SourceVersion.objects.filter(
mnemonic='version3',
versioned_object_type=ContentType.objects.get_for_model(Source),
versioned_object_id=self.source1.id
).exists())
self.assertEquals(version2, version3.previous_version)
self.assertEquals(version2.mnemonic, version3.previous_version_mnemonic)
self.assertIsNone(version3.parent_version)
self.assertIsNone(version3.parent_version_mnemonic)
self.assertEquals(3, self.source1.num_versions)