def test_bool_field(): class Person(models.Base): has_childen = fields.BoolField() schema = Person.to_json_schema() pattern = get_fixture('schema5.json') assert compare_schemas(pattern, schema) is True
def test_datetime_fields(): class Event(models.Base): time = fields.TimeField() date = fields.DateField() end = fields.DateTimeField() schema = Event.to_json_schema() pattern = get_fixture('schema4.json') assert compare_schemas(pattern, schema) is True
def test_validators_can_modify_schema(): class ClassBasedValidator(object): def validate(self, value): raise RuntimeError() def modify_schema(self, field_schema): field_schema['some'] = 'unproper value' def function_validator(value): raise RuntimeError() class Person(models.Base): name = fields.StringField(validators=ClassBasedValidator()) surname = fields.StringField(validators=function_validator) for person in [Person, Person()]: schema = person.to_json_schema() pattern = get_fixture('schema6.json') assert compare_schemas(pattern, schema) is True
def test_generate_circular_schema2(): schema = Filesystem.to_json_schema() pattern = get_fixture('schema_circular2.json') assert compare_schemas(pattern, schema) is True
def test_generate_circular_schema(): schema = Primary.to_json_schema() pattern = get_fixture('schema_circular.json') assert compare_schemas(pattern, schema) is True