Example #1
0
def test_empty_arrays(xsd42, minimal_json42, field_name):
    """Test proper behavior with empty lists for certain fields."""
    minimal_json42[field_name] = []
    validator.validate(minimal_json42)
    xsd42.assertValid(etree.XML(tostring(minimal_json42).encode('utf8')))
Example #2
0
def test_minimal_xsd(xsd42, minimal_json42):
    """Test that example XML converts to example JSON."""
    validator.validate(minimal_json42)
    xsd42.assertValid(etree.XML(tostring(minimal_json42).encode('utf8')))
Example #3
0
def validate_json(minimal_json, extra_json):
    """Validate specific property."""
    data = {}
    data.update(minimal_json)
    data.update(extra_json)
    validator.validate(data)
Example #4
0
def test_example_json_validates(example_json43):
    """Test the example file validates against the JSON schema."""
    example_json = load_json_path(example_json43)
    validator.validate(example_json)
import json
from datacite.schema43 import validate, validator

infile = 'park_falls.json'

metaf = open(infile, 'r')
metadata = json.load(metaf)

valid = validate(metadata)
# Debugging if verification fails
if valid == False:
    v = validator.validate(metadata)
    errors = sorted(v.iter_errors(instance), key=lambda e: e.path)
    for error in errors:
        print(error.message)