示例#1
0
 def test_create_identifier_without_parent(self):
     data = {"scheme": "IC", "identifier": "129031309"}
     serializer = IdentifierSerializer(data=data, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     with self.assertRaises(ContentObjectNotAvailable):
         serializer.save()
示例#2
0
    def test_update_identifier(self):
        data = {"identifier": "53110322"}
        person = Person.objects.language("en").get(id="8497ba86-7485-42d2-9596-2ab14520f1f4")
        identifier = person.identifiers.language("en").get(id="34b59cb9-607a-43c7-9d13-dfe258790ebf")
        serializer = IdentifierSerializer(identifier, data, language="en", partial=True)
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save()

        person_ = Person.objects.language("en").get(id="8497ba86-7485-42d2-9596-2ab14520f1f4")
        identifier = person_.identifiers.language("en").get(id="34b59cb9-607a-43c7-9d13-dfe258790ebf")
        self.assertEqual(identifier.identifier, "53110322")
示例#3
0
    def test_create_identifier(self):
        person = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")
        data = {"scheme": "IC", "identifier": "129031309"}
        serializer = IdentifierSerializer(data=data, language="en")
        serializer.is_valid()
        self.assertEqual(serializer.errors, {})
        serializer.save(content_object=person)

        person_ = Person.objects.language("en").get(id="ab1a5788e5bae955c048748fa6af0e97")

        identifier = person_.identifiers.language("en").get(identifier="129031309")
        self.assertEqual(identifier.scheme, "IC")
 def test_create_person_identifier(self):
     person = Person.objects.language("en").get(id="078541c9-9081-4082-b28f-29cbb64440cb")
     data = {
         "identifier": "123121231",
         "scheme":"test_identifier"
     }
     serializer = IdentifierSerializer(data=data, language="en")
     serializer.is_valid()
     self.assertEqual(serializer.errors, {})
     serializer.save(content_object=person)
     identifiers = person.identifiers.language("en").get(identifier="123121231")
     self.assertEqual(identifiers.scheme, "test_identifier")