def validator(self, datastore, test_index, test_doc_type):
        test_schema = {
            'type': 'object',
            'required': ['name', 'age'],
            'x-es-mapping': {
                'properties': {
                    'nickname': {
                        'type': 'string'
                    },
                    'name': {
                        'type': 'string'
                    },
                    'age': {
                        'type': 'integer'
                    },
                    'user': {
                        'type': 'string'
                    },
                    'host': {
                        'type': 'string'
                    },
                }
            },
            'x-unique-together': [['name', 'age'], ['user', 'host']],
            'x-unique': [
                'nickname',
            ],
            'properties': {
                'id': {
                    'type': 'string'
                },
                'name': {
                    'type': 'string'
                },
                'age': {
                    'type': 'integer'
                },
                'user': {
                    'type': 'string'
                },
                'host': {
                    'type': 'string'
                },
            }
        }

        configure_mappings(test_index,
                           {'definitions': {
                               test_doc_type: test_schema
                           }}, datastore._es)

        return CustomDraft4Validator(test_schema,
                                     datastore=datastore,
                                     upload_path=gettempdir(),
                                     index=test_index,
                                     doc_type=test_doc_type)
Exemple #2
0
    def validator(self, datastore):
        test_schema = {
            'type': 'object',
            'required': ['smoking'],
            'properties': {
                'smoking': {
                    'enum': ['allowed', 'forbidden', 'seperate_room', '5'],

                }
            }
        }

        return CustomDraft4Validator(
            test_schema,
            datastore=datastore,
            upload_path=gettempdir(),
        )
def validator(datastore):
    test_schema = {
        'type': 'object',
        'id': 'company',
        'required': ['name'],
        'properties': {
            'name': {
                'type': 'string',
                'pattern': 'into[A-Z]\w*',
            }
        }
    }

    return CustomDraft4Validator(
        test_schema,
        datastore=datastore,
        upload_path=gettempdir(),
    )
    def validator(self, datastore, test_index, test_doc_type):
        test_schema = {
            'type': 'object',
            'properties': {
                'geolocation': {
                    'type': 'object',
                    'x-check-geolocation': {
                        'address_field': 'postal_address',
                        'geopoint_field': 'geo_point',
                        'geopoint_deviation': 55,
                        'override_field': 'do_not_check',
                    },
                    'properties': {
                        'postal_address': {
                            'type': 'string'
                        },
                        'administrative_areas': {
                            'type': 'array',
                            'items': {
                                'type': 'string'
                            }
                        },
                        'geo_point': {
                            'type': 'string'
                        },
                        'do_not_check': {
                            'type': 'boolean',
                            'default': False,
                        }
                    }
                }
            }
        }

        configure_mappings(test_index,
                           {'definitions': {
                               test_doc_type: test_schema
                           }}, datastore._es)

        return CustomDraft4Validator(test_schema,
                                     datastore=datastore,
                                     upload_path=gettempdir(),
                                     index=test_index,
                                     doc_type=test_doc_type)
Exemple #5
0
    def validator(self, datastore):
        test_schema = {
            'type': 'object',
            'required': [
                'sys_filename',
            ],
            'properties': {
                'sys_filename': {
                    'type': 'string',
                    'x-file': True
                }
            }
        }

        return CustomDraft4Validator(
            test_schema,
            datastore=datastore,
            upload_path=gettempdir(),
        )
def int_validator(datastore):
    test_schema = {
        'type': 'object',
        'id': 'company',
        'required': ['mandatory'],
        'properties': {
            'mandatory': {
                'type': 'integer'
            },
            'optional': {
                'type': 'string'
            },
        }
    }

    return CustomDraft4Validator(
        test_schema,
        datastore=datastore,
        upload_path=gettempdir(),
    )
def validator(datastore):
    test_schema = {
        'type': 'object',
        'id': 'company',
        'properties': {
            'tags': {
                'type': 'array',
                'items': {'type': 'string'},
                'minItems': 1,
                'uniqueItems': True,
            },
            'flags': {
                'type': 'array',
                'items': {'type': 'integer'},
                'maxItems': 3,
            },
        }
    }

    return CustomDraft4Validator(
        test_schema,
        datastore=datastore,
        upload_path=gettempdir(),
    )