How to use the jsonmodels.utils.compare_schemas function in jsonmodels

To help you get started, we’ve selected a few jsonmodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_schema_for_list_and_primitives(self):

        class Event(models.Base):

            time = fields.TimeField()
            date = fields.DateField()
            end = fields.DateTimeField()

        class Person(models.Base):

            names = fields.ListField([str, int, Event])

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_with_list.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
name = fields.StringField()
            os = fields.StringField()

        class Person(models.Base):

            name = fields.StringField(required=True)
            surname = fields.StringField(required=True)
            age = fields.IntField()
            car = fields.EmbeddedField([Viper, Lamborghini])
            computer = fields.ListField([PC, Laptop, Tablet])

        chuck = Person()
        schema = chuck.to_json_schema()

        pattern = get_fixture('schema3.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_min_validator_with_exclusive(self):

        class Person(models.Base):

            name = fields.StringField()
            surname = fields.StringField()
            age = fields.IntField(validators=validators.Min(18, True))

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_min_exclusive.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_max_validator(self):

        class Person(models.Base):

            name = fields.StringField()
            surname = fields.StringField()
            age = fields.IntField(validators=validators.Max(18))

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_max.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
class Person(models.Base):

            def __init__(self, some_value):
                pass

            name = fields.StringField(required=True)
            surname = fields.StringField(required=True)
            age = fields.IntField()
            kids = fields.ListField(Kid)
            car = fields.EmbeddedField(Car)

        schema = Person.to_json_schema()

        pattern = get_fixture('schema2.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_regex_validator_when_ecma_regex_given(self):

        class Person(models.Base):

            name = fields.StringField(
                validators=validators.Regex('/^some pattern$/'))

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_pattern.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_length_validator_min(self):

        class Person(models.Base):

            name = fields.StringField(validators=validators.Length(5))
            surname = fields.StringField()
            age = fields.IntField()

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_length_min.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_model1(self):

        class Person(models.Base):

            name = fields.StringField(required=True)
            surname = fields.StringField(required=True)
            age = fields.IntField()

        alan = Person()
        schema = alan.to_json_schema()

        pattern = get_fixture('schema1.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_min_validator(self):

        class Person(models.Base):

            name = fields.StringField()
            surname = fields.StringField()
            age = fields.IntField(validators=validators.Min(18))

        schema = Person.to_json_schema()

        pattern = get_fixture('schema_min.json')
        self.assertTrue(compare_schemas(pattern, schema))
github jazzband / jsonmodels / tests / test_schema.py View on Github external
def test_bool_field(self):

        class Person(models.Base):

            has_childen = fields.BoolField()

        schema = Person.to_json_schema()

        pattern = get_fixture('schema5.json')
        self.assertTrue(compare_schemas(pattern, schema))