|
|
|
@ -3,21 +3,31 @@ import json
|
|
|
|
|
import pytest
|
|
|
|
|
from jsonschema import validate
|
|
|
|
|
|
|
|
|
|
def validate_json(jsonfile: str, schemafile: str) -> bool:
|
|
|
|
|
with open(jsonfile, 'r') as f:
|
|
|
|
|
def test_validate_manifest_against_local_schema():
|
|
|
|
|
"""Ensures that the manifest matches the local schema, for situations where the schema is being changed."""
|
|
|
|
|
json_relative: str = '../sherlock/resources/data.json'
|
|
|
|
|
schema_relative: str = '../sherlock/resources/data.schema.json'
|
|
|
|
|
|
|
|
|
|
json_path: str = os.path.join(os.path.dirname(__file__), json_relative)
|
|
|
|
|
schema_path: str = os.path.join(os.path.dirname(__file__), schema_relative)
|
|
|
|
|
|
|
|
|
|
with open(json_path, 'r') as f:
|
|
|
|
|
jsondat = json.load(f)
|
|
|
|
|
with open(schemafile, 'r') as f:
|
|
|
|
|
with open(schema_path, 'r') as f:
|
|
|
|
|
schemadat = json.load(f)
|
|
|
|
|
|
|
|
|
|
validate(instance=jsondat, schema=schemadat)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def test_validate_manifest_against_schema():
|
|
|
|
|
|
|
|
|
|
def test_validate_manifest_against_remote_schema(remote_schema):
|
|
|
|
|
"""Ensures that the manifest matches the remote schema, so as to not unexpectedly break clients."""
|
|
|
|
|
json_relative: str = '../sherlock/resources/data.json'
|
|
|
|
|
schema_relative: str = '../sherlock/resources/data.schema.json'
|
|
|
|
|
|
|
|
|
|
json_path: str = os.path.join(os.path.dirname(__file__), json_relative)
|
|
|
|
|
schema_path: str = os.path.join(os.path.dirname(__file__), schema_relative)
|
|
|
|
|
validate_json(jsonfile=json_path, schemafile=schema_path)
|
|
|
|
|
|
|
|
|
|
with open(json_path, 'r') as f:
|
|
|
|
|
jsondat = json.load(f)
|
|
|
|
|
|
|
|
|
|
validate(instance=jsondat, schema=remote_schema)
|
|
|
|
|
|
|
|
|
|
# Ensure that the expected values are beind returned by the site list
|
|
|
|
|
@pytest.mark.parametrize("target_name,target_expected_err_type", [
|
|
|
|
|