Skip to content

Commit

Permalink
fix bad_top_level_field
Browse files Browse the repository at this point in the history
  • Loading branch information
colltoaction committed Aug 21, 2024
1 parent d377d78 commit 53a8a93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
3 changes: 2 additions & 1 deletion schemas/hif_schema_v0.1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
},
"unevaluatedProperties": false
},
"required": ["incidences"]
"required": ["incidences"],
"additionalProperties": false
}
11 changes: 4 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import pytest
import requests
import fastjsonschema

schema_location = "https://raw.githubusercontent.com/pszufe/HIF_validators/main/schemas/hif_schema_v0.1.0.json"
schema = "schemas/hif_schema_v0.1.0.json"
json_dir = "tests/test_files"


@pytest.fixture
def schema():
r = requests.get(schema_location)

if r.ok:
return r.json()

def validator():
return fastjsonschema.compile(json.load(open(schema)))

@pytest.fixture
def empty():
Expand Down
13 changes: 4 additions & 9 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import fastjsonschema
import pytest


def test_empty(schema, empty):
validator = fastjsonschema.compile(schema)
def test_empty(validator, empty):
with pytest.raises(ValueError):
validator(empty)


def test_bad_top_level_field(schema, bad_top_level_field):
validator = fastjsonschema.compile(schema)
def test_bad_top_level_field(validator, bad_top_level_field):
with pytest.raises(ValueError):
validator(bad_top_level_field)


def test_metadata_as_list(schema, metadata_as_list):
validator = fastjsonschema.compile(schema)
def test_metadata_as_list(validator, metadata_as_list):
with pytest.raises(ValueError):
validator(metadata_as_list)


def test_empty_hypergraph(schema, empty_hypergraph):
validator = fastjsonschema.compile(schema)
def test_empty_hypergraph(validator, empty_hypergraph):
validator(empty_hypergraph)

0 comments on commit 53a8a93

Please sign in to comment.