-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic valid and invalid tests for the json schema #141
Add basic valid and invalid tests for the json schema #141
Conversation
cc @m-mohr do you think this is a sensible approach to test the json schema? (ensure it passes when it should and errors when it should) |
I'll have a look in the next days :-) |
OK, I updated this PR for the latest changes in the spec and updated to use pytest. This should be ready for review. |
Looks reasonable to me. Why commit the test files when you can always generate them on the fly though? May lead to PRs where people update them by hand... |
fb67fa6
to
33ef4b6
Compare
I'd like to propose some additional checks: metadata = copy.deepcopy(metadata_template)
metadata["columns"]["invalid_column_object"] = {"foo": "bar"}
invalid_cases["invalid_column_object"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = [0,0,0]
invalid_cases["3_element_bbox"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = [0,0,0,0]
valid_cases["4_element_bbox"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = ["0","0","0","0"]
invalid_cases["bbox_invalid_type"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = [0,0,0,0,0]
invalid_cases["5_element_bbox"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = [0.0,0.0,0.0,0.0,0.0,0.0]
valid_cases["6_element_bbox"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["bbox"] = [0,0,0,0,0,0,0]
invalid_cases["7_element_bbox"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"][""] = metadata["columns"]["geometry"]
invalid_cases["empty_column_name"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["primary_geometry"] = ""
invalid_cases["empty_primary_geometry"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["geometry_types"] = ["Point", "Point"]
invalid_cases["geometry_type_uniqueness"] = metadata
metadata = copy.deepcopy(metadata_template)
metadata["columns"]["geometry"]["geometry_types"] = ["PointZ"]
invalid_cases["geometry_type_missing_space"] = metadata
|
@m-mohr thanks for those additional cases! This one I don't fully understand what it is testing for:
|
|
||
metadata = copy.deepcopy(metadata_template) | ||
metadata["columns"] = {} | ||
invalid_cases["missing_columns_entry"] = metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is still failing (it is xfailed for now to have the tests passing):
E AssertionError: This is an invalid GeoParquet file, but no validation error occurred for 'missing_columns_entry':
E {
E "geo": {
E "columns": {},
E "primary_column": "geometry",
E "version": "0.5.0-dev"
E }
E }
But I suppose that should be easy to solve to require a minimum length of one for columns
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. We can fix that, sure. Just add "minProperties": 1,
in the columns schema.
By the way, the written spec doesn't forbid an empty column object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
"columns": {
"type": "object",
"minProperties": 1,
"patternProperties": {
".+": {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or use/merge #158.
@jorisvandenbossche In #153 we require a minimum length of 1 for the primary geometry and I'm trying to check whether the schema fails for an empty primary geometry. But I just now realize that it's wrong and should be: metadata = copy.deepcopy(metadata_template)
metadata["primary_geometry"] = ""
invalid_cases["empty_primary_geometry"] = metadata |
OK, that one is already included! |
Would there be support for moving the |
I wouldn't mind that, certainly now it is only a single file (I am also already making use of the python dependencies that are installed for the scripts to run the tests in CI) |
I moved this script in #159 and updated it to read the version constant from the schema file. So the tests now assert that metadata without a version or with a version that is different than the schema version is invalid. |
Closes #135 (rework of #134 to focus on json schema for now)