Esempio n. 1
0
 def test_validate_raises(self):
     uuids = [
         '1203a23f-032c-46be-a1fa-c85fd0284b4c',
         '22e6a469-a4fd-415e-8c22-b8d73856a714', 'no_uuid_value'
     ]
     objects = self._test_objects(uuids)
     field = ListSerializerField(self.TestSerializer, required=True)
     field.set_value(value=objects)
     self.assertRaises(SerializerFieldValueError, field.validate)
Esempio n. 2
0
    def test_set_value(self):
        uuids = [
            '0203a23f-032c-46be-a1fa-c85fd0284b4c',
            'd2e6a469-a4fd-415e-8c22-b8d73856a714',
            '8832f5cd-c024-49ce-b27a-8d6e388f3b08'
        ]
        objects = self._test_objects(uuids)
        field = ListSerializerField(self.TestSerializer, required=True)

        field.set_value(value=objects)
        field.validate()
        for value in field.to_python():
            self.assertIn(str(value.get('uuid')), uuids)
            self.assertIn(str(value.get('name')), ['ONE', 'TWO', 'THREE'])
Esempio n. 3
0
 class ASerializer(Serializer):
     _type = TypeField('', fixed=False)
     objects = ListSerializerField(ListItemSerialzer, required=True)
Esempio n. 4
0
class RecursionRefSerializerOne(Serializer):
    name = StringField()
    sers = ListSerializerField('RecursionRefSerializerTwo',
                               exclude=['ser'],
                               required=False)