本文整理汇总了Python中concepts.models.ConceptVersion.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python ConceptVersion.full_clean方法的具体用法?Python ConceptVersion.full_clean怎么用?Python ConceptVersion.full_clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类concepts.models.ConceptVersion
的用法示例。
在下文中一共展示了ConceptVersion.full_clean方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_concept_version_positive
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
def test_create_concept_version_positive(self):
self.assertEquals(1, self.concept1.num_versions)
concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=self.concept1,
concept_class='First',
names=self.concept1.names,
created_by=self.user1.username,
updated_by=self.user1.username,
version_created_by=self.user1.username,
)
concept_version.full_clean()
concept_version.save()
self.assertTrue(ConceptVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Concept),
versioned_object_id=self.concept1.id,
).exists())
self.assertEquals(2, self.concept1.num_versions)
self.assertEquals(concept_version, ConceptVersion.get_latest_version_of(self.concept1))
self.assertEquals(self.concept1.mnemonic, concept_version.name)
self.assertEquals(self.concept1.owner_name, concept_version.owner_name)
self.assertEquals(self.concept1.owner_type, concept_version.owner_type)
self.assertEquals(self.concept1.display_name, concept_version.display_name)
self.assertEquals(self.concept1.display_locale, concept_version.display_locale)
示例2: test_create_concept_version_negative__no_concept_class
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
def test_create_concept_version_negative__no_concept_class(self):
with self.assertRaises(ValidationError):
concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=self.concept1,
names=[self.name],
)
concept_version.full_clean()
concept_version.save()
示例3: test_concept_version_clone
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
def test_concept_version_clone(self):
self.assertEquals(1, self.concept1.num_versions)
concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=self.concept1,
concept_class='First',
names=self.concept1.names,
created_by=self.user1.username,
updated_by=self.user1.username,
version_created_by=self.user1.username,
)
concept_version.full_clean()
concept_version.save()
self.assertTrue(ConceptVersion.objects.filter(
mnemonic='version1',
versioned_object_type=ContentType.objects.get_for_model(Concept),
versioned_object_id=self.concept1.id,
).exists())
self.assertEquals(2, self.concept1.num_versions)
self.assertEquals(concept_version, ConceptVersion.get_latest_version_of(self.concept1))
self.assertEquals(self.concept1.mnemonic, concept_version.name)
self.assertEquals(self.concept1.owner_name, concept_version.owner_name)
self.assertEquals(self.concept1.owner_type, concept_version.owner_type)
self.assertEquals(self.concept1.display_name, concept_version.display_name)
self.assertEquals(self.concept1.display_locale, concept_version.display_locale)
version2 = concept_version.clone()
version2.mnemonic = 'version2'
version2.created_by = self.user1.username
version2.updated_by = self.user1.username
version2.version_created_by = self.user1.username
version2.full_clean()
version2.save()
self.assertEquals(3, self.concept1.num_versions)
self.assertEquals(version2, ConceptVersion.get_latest_version_of(self.concept1))
self.assertEquals(concept_version, version2.previous_version)
self.assertEquals(concept_version.public_access, version2.public_access)
self.assertEquals(self.concept1, version2.versioned_object)
self.assertEquals(self.concept1.mnemonic, version2.name)
self.assertEquals(self.concept1.owner_name, version2.owner_name)
self.assertEquals(self.concept1.owner_type, version2.owner_type)
self.assertEquals(self.concept1.display_name, version2.display_name)
self.assertEquals(self.concept1.display_locale, version2.display_locale)
示例4: test_add_duplicate_concept_reference_different_version_number
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
def test_add_duplicate_concept_reference_different_version_number(self):
source_with_open_mrs, user = self.create_source_and_user_fixture()
collection = create_collection(user, CUSTOM_VALIDATION_SCHEMA_OPENMRS)
(concept_one, errors) = create_concept(mnemonic="ConceptOne", user=self.user1, source=source_with_open_mrs, names=[
create_localized_text(name='UserOne', locale='es', type='FULLY_SPECIFIED')])
data = json.dumps({
'data': {
'expressions': [concept_one.url]
}
})
kwargs = {'user': user.username, 'collection': collection.name}
self.client.put(reverse('collection-references', kwargs=kwargs), data,
content_type='application/json')
concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=concept_one,
concept_class='Diagnosis',
datatype=concept_one.datatype,
names=concept_one.names,
created_by=self.user1.username,
updated_by=self.user1.username,
version_created_by=self.user1.username,
descriptions=[create_localized_text("aDescription")])
concept_version.full_clean()
concept_version.save()
data = json.dumps({
'data': {
'expressions': [concept_version.url]
}
})
response = self.client.put(reverse('collection-references', kwargs=kwargs), data,
content_type='application/json')
self.assertEquals(response.status_code, status.HTTP_200_OK)
self.assertEquals(response.data, [{'added': False, 'expression': concept_version.url,
'message': [REFERENCE_ALREADY_EXISTS]}])
示例5: test_concept_version_inherits_public_access__positive
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
def test_concept_version_inherits_public_access__positive(self):
public_access = self.source1.public_access
self.assertEquals(1, self.concept1.num_versions)
concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=self.concept1,
concept_class='First',
public_access=public_access,
names=self.concept1.names,
created_by=self.user1.username,
updated_by=self.user1.username,
version_created_by=self.user1.username,
)
concept_version.full_clean()
concept_version.save()
self.assertEquals(self.source1.public_access, concept_version.public_access)
self.source1.public_access = ACCESS_TYPE_VIEW
self.source1.save()
self.assertNotEquals(public_access, self.source1.public_access)
concept_version = ConceptVersion.objects.get(id=concept_version.id)
self.assertEquals(self.source1.public_access, concept_version.public_access)
示例6: ConceptVersionStaticMethodsTest
# 需要导入模块: from concepts.models import ConceptVersion [as 别名]
# 或者: from concepts.models.ConceptVersion import full_clean [as 别名]
class ConceptVersionStaticMethodsTest(ConceptBaseTest):
def setUp(self):
super(ConceptVersionStaticMethodsTest, self).setUp()
self.concept1 = Concept(
mnemonic='concept1', concept_class='First', public_access=ACCESS_TYPE_EDIT)
display_name = LocalizedText(name='concept1', locale='en')
self.concept1.names.append(display_name)
kwargs = {
'parent_resource': self.source1,
}
Concept.persist_new(self.concept1, self.user1, **kwargs)
initial_version = ConceptVersion.get_latest_version_of(self.concept1)
self.concept2 = Concept(mnemonic='concept2', concept_class='Second', names=[self.name])
kwargs = {
'parent_resource': self.source2,
}
Concept.persist_new(self.concept2, self.user1, **kwargs)
self.concept_version = ConceptVersion(
mnemonic='version1',
versioned_object=self.concept1,
concept_class='First',
names=self.concept1.names,
previous_version=initial_version,
created_by=self.user1.username,
updated_by=self.user1.username,
version_created_by=self.user1.username,
)
self.concept_version.full_clean()
self.concept_version.save()
def test_for_concept_positive(self):
self.concept1.datatype = 'Boolean'
self.concept1.save()
label = 'version1'
version = ConceptVersion.for_concept(self.concept1, label)
self.assertEquals(label, version.mnemonic)
self.assertEquals(self.concept1, version.versioned_object)
self.assertEquals(self.concept1.concept_class, version.concept_class)
self.assertEquals(self.concept1.datatype, version.datatype)
self.assertEquals(self.concept1.names, version.names)
self.assertEquals(self.concept1.descriptions, version.descriptions)
self.assertEquals(self.concept1.retired, version.retired)
self.assertEquals(self.concept1.public_access, version.public_access)
self.assertEquals(self.concept1.external_id, version.external_id)
self.assertFalse(version.released)
def test_persist_clone_positive(self):
self.assertEquals(2, self.concept1.num_versions)
self.assertEquals(
self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))
source_version = SourceVersion.get_latest_version_of(self.source1)
source_version.update_concept_version(self.concept_version)
self.assertEquals(1, len(source_version.concepts))
self.assertEquals(self.concept_version.id, source_version.concepts[0])
version2 = self.concept_version.clone()
errors = ConceptVersion.persist_clone(version2, self.user1)
self.assertEquals(0, len(errors))
self.assertEquals(3, self.concept1.num_versions)
self.assertEquals(version2, ConceptVersion.get_latest_version_of(self.concept1))
self.assertEquals(self.concept_version.public_access, version2.public_access)
self.assertEquals(self.concept_version, version2.previous_version)
self.assertEquals(self.concept_version.root_version, version2.root_version)
self.assertEquals(self.concept_version.external_id, version2.external_id)
self.assertEquals(self.user1.username, version2.version_created_by)
source_version.update_concept_version(version2)
self.assertEquals(1, len(source_version.concepts))
self.assertEquals(version2.id, source_version.concepts[0])
def test_persist_clone_negative__no_user(self):
self.assertEquals(2, self.concept1.num_versions)
self.assertEquals(
self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))
source_version = SourceVersion.get_latest_version_of(self.source1)
source_version.update_concept_version(self.concept_version)
self.assertEquals(1, len(source_version.concepts))
self.assertEquals(self.concept_version.id, source_version.concepts[0])
version2 = self.concept_version.clone()
errors = ConceptVersion.persist_clone(version2)
self.assertEquals(1, len(errors))
self.assertTrue('version_created_by' in errors)
self.assertEquals(2, self.concept1.num_versions)
self.assertEquals(
self.concept_version, ConceptVersion.get_latest_version_of(self.concept1))