Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python_jsonschema_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ def __init__(self, schema_uri, resolved={}):
}
)

meta_validator = Draft4Validator(Draft4Validator.META_SCHEMA)
meta_validator.validate(self.schema)
self.validator = Draft4Validator(self.schema,
resolver=self.resolver)


self._classes = None
self._resolved = None

Expand Down
21 changes: 19 additions & 2 deletions test/test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,38 @@

import json
import six
import pkg_resources
import jsonschema
import python_jsonschema_objects as pjs

import logging
logging.basicConfig(level=logging.DEBUG)


def test_schema_validation():
""" Test that the ObjectBuilder validates the schema itself.
"""
schema = {
"$schema": "http://json-schema.org/schema#",
"id": "test",
"type": "object",
"properties": {
"name": "string",
"email": {"oneOf": [{"type": "string"}, {"type": "integer"}]},
},
"required": ["email"]
}
with pytest.raises(jsonschema.ValidationError):
pjs.ObjectBuilder(schema)


def test_regression_9():
schema = {
"$schema": "http://json-schema.org/schema#",
"id": "test",
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"oneOf": ["string", "integer"]},
"email": {"oneOf": [{"type": "string"}, {"type": "integer"}]},
},
"required": ["email"]
}
Expand Down
1 change: 0 additions & 1 deletion test/test_regression_17.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_class():
"id": "claimed",
"type": ["string", "integer", "null"],
"description": "Robots Only. The human agent that has claimed this robot.",
"required": False
},
}
}
Expand Down