def test_char_field_serializer(): from rest_framework_schemaform.models import CharFieldModel model = CharFieldModel() model.field = u'My CharFieldTest' model.save() serializer = JsonSchemaSerializer(model) result = serializer.to_representation(model) assert 'field' == result.get('properties').get('field').get('key') assert 'Field Title' == result.get('properties').get('field').get('title') assert 'Field Help Text' == result.get('properties').get('field').get('description') # noqa assert 'string' == result.get('properties').get('field').get('type') assert 'integer' == result.get('properties').get('id').get('type')
def test_foreign_key_field_serializer(): from rest_framework_schemaform.models import CharFieldModel from rest_framework_schemaform.models import ForeignKeyModel reference = CharFieldModel() reference.field = u'My CharFieldTest' reference.save() model = ForeignKeyModel() model.field = reference model.save() serializer = JsonSchemaSerializer(model) result = serializer.to_representation(model) assert 'string' == result.get('properties').get('field').get('type')