def test_json(app, base_json):
    print("\n\n\n\n\n")
    print("START")
    print(app)
    print(current_jsonschemas.list_schemas())
    _records_state.validate(
        base_json, "https://nusl.cz/schemas/nr_theses/nr-theses-v1.0.0.json")
Esempio n. 2
0
def test_json(app, base_json, base_event):
    print("\n\n\n\n\n")
    print("START")
    print(app)
    print(current_jsonschemas.list_schemas())
    base_json["events"] = [base_event]
    _records_state.validate(
        base_json, "https://nusl.cz/schemas/nr_events/nr-events-v1.0.0.json")
Esempio n. 3
0
def test_json(app, base_json, base_nresult):
    print("\n\n\n\n\n")
    print("START")
    print(app)
    print(current_jsonschemas.list_schemas())
    base_json.update(base_nresult)
    pprint(base_json)
    _records_state.validate(
        base_json,
        "https://nusl.cz/schemas/nr_nresults/nr-nresults-v1.0.0.json")
def test_json_2(app, base_json):
    print("\n\n\n\n\n")
    print("START")
    print(app)
    print(current_jsonschemas.list_schemas())
    del base_json["title"]
    with pytest.raises(ValidationError):
        _records_state.validate(
            base_json,
            "https://nusl.cz/schemas/nr_common/nr-common-v1.0.0.json")
Esempio n. 5
0
    def __call__(self, uri, **kwargs):
        """Method invoked when an uri has to be resolved.

        If URI is present in registered JSON schemas list, it resolves in the
        common schemas, else lets the loader from jsonref do the job.
        """
        if uri in current_jsonschemas.list_schemas():
            return current_jsonschemas.get_schema(uri)

        return super(CustomJsonLoader, self).__call__(uri, *kwargs)
Esempio n. 6
0
    def _register_draft_schemas(self, app):
        for config in app.config.get('INVENIO_RECORD_DRAFT_SCHEMAS', []):
            config = self.preprocess_config(config)

            published_schema = config['published_schema']
            draft_schema = config['draft_schema']

            if draft_schema in current_jsonschemas.list_schemas():
                continue

            self.published_schemas[published_schema] = config
            self.draft_schemas[draft_schema] = config

            full_path = os.path.join(
                app.config['INVENIO_RECORD_DRAFT_SCHEMAS_DIR'], draft_schema)

            if not os.path.exists(full_path):  # pragma: no cover
                print('Draft schema %s not found. '
                      'Please call invenio draft make-schemas' % draft_schema)
                continue

            current_jsonschemas.register_schema(
                app.config['INVENIO_RECORD_DRAFT_SCHEMAS_DIR'], draft_schema)
Esempio n. 7
0
def test_schemas_deployed(app, schemas):
    for schema in app.config['INVENIO_RECORD_DRAFT_SCHEMAS']:
        schema = current_drafts.preprocess_config(schema)
        assert schema['draft_schema'] in current_jsonschemas.list_schemas()
Esempio n. 8
0
def list_schemas_impl():
    """List all schemas registered in invenio."""
    for schema in current_jsonschemas.list_schemas():
        print("   ", schema)