-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improved Trajectory and VerticalProfile domain tests * Added tests for all remaining domain types (Point and Polygon-based domains, plus Section) * Added tests for empty axes
- Loading branch information
Jon Blower
authored
Apr 22, 2022
1 parent
5597a78
commit b986422
Showing
67 changed files
with
3,430 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$id": "/schemas/stringSingleValueAxis", | ||
"description" : "Axis defined by single string value", | ||
"allOf" : | ||
[ | ||
{ "$ref": "/schemas/stringValuesAxis" }, | ||
{ | ||
"properties" : | ||
{ | ||
"values" : | ||
{ | ||
"maxItems" : 1 | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Pytests to test the MultiPoint domain type in the domain.json schema file | ||
|
||
import pytest | ||
from jsonschema.exceptions import ValidationError | ||
|
||
pytestmark = pytest.mark.schema("/schemas/domain") | ||
|
||
|
||
@pytest.mark.exhaustive | ||
def test_valid_multipoint_domain(validator, multipoint_domain): | ||
''' Tests an example of a MultiPoint domain ''' | ||
|
||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_missing_composite_axis(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with missing 'composite' axis ''' | ||
|
||
del multipoint_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_empty_composite_axis(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with empty 'composite' axis ''' | ||
|
||
multipoint_domain["axes"]["composite"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_composite_axis_with_1_value(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with composite axis with tuples of length 1 ''' | ||
|
||
multipoint_domain["axes"]["composite"]["values"] = [ | ||
[1], | ||
[2], | ||
[3] | ||
] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_composite_axis_with_4_values(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with composite axis with tuples of length 4 ''' | ||
|
||
multipoint_domain["axes"]["composite"]["values"] = [ | ||
["2008-01-01T04:00:00Z", 1, 1, 1], | ||
["2008-01-01T05:00:00Z", 2, 2, 2], | ||
["2008-01-01T06:00:00Z", 3, 3, 3] | ||
] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_wrong_composite_axis_type(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with primitive instead of tuple axis ''' | ||
|
||
multipoint_domain["axes"]["composite"] = { | ||
"values": [1, 2, 3] | ||
} | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_extra_axis(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with unrecognised extra axis ''' | ||
|
||
multipoint_domain["axes"]["composite2"] = \ | ||
multipoint_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_multivalued_t_axis(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with multi-valued 't' axis ''' | ||
|
||
multipoint_domain["axes"]["t"] = { "values" : ["2008-01-01T04:00:00Z", "2008-01-01T05:00:00Z"] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
def test_empty_t_axis(validator, multipoint_domain): | ||
''' Invalid: MultiPoint domain with empty 't' axis ''' | ||
|
||
multipoint_domain["axes"]["t"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipoint_domain) | ||
|
||
|
||
# TODO test coordinate identifiers of 'composite' axis | ||
# to be "x","y","z" or "x","y" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Pytests to test the MultiPointSeries domain type in the domain.json schema file | ||
|
||
import pytest | ||
from jsonschema.exceptions import ValidationError | ||
|
||
pytestmark = pytest.mark.schema("/schemas/domain") | ||
|
||
|
||
@pytest.mark.exhaustive | ||
def test_valid_multipointseries_domain(validator, multipointseries_domain): | ||
''' Tests an example of a MultiPointSeries domain ''' | ||
|
||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_missing_composite_axis(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with missing 'composite' axis ''' | ||
|
||
del multipointseries_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_empty_composite_axis(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with empty 'composite' axis ''' | ||
|
||
multipointseries_domain["axes"]["composite"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_missing_t_axis(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with missing 't' axis ''' | ||
|
||
del multipointseries_domain["axes"]["t"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_empty_t_axis(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with empty 't' axis ''' | ||
|
||
multipointseries_domain["axes"]["t"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_wrong_composite_axis_type(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with primitive instead of tuple axis ''' | ||
|
||
multipointseries_domain["axes"]["composite"] = { | ||
"values": [1, 2, 3] | ||
} | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_composite_axis_with_1_value(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with composite axis with tuples of length 1 ''' | ||
|
||
multipointseries_domain["axes"]["composite"]["values"] = [ | ||
[1], | ||
[2], | ||
[3] | ||
] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_composite_axis_with_4_values(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with composite axis with tuples of length 4 ''' | ||
|
||
multipointseries_domain["axes"]["composite"]["values"] = [ | ||
["2008-01-01T04:00:00Z", 1, 1, 1], | ||
["2008-01-01T05:00:00Z", 2, 2, 2], | ||
["2008-01-01T06:00:00Z", 3, 3, 3] | ||
] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
def test_extra_axis(validator, multipointseries_domain): | ||
''' Invalid: MultiPointSeries domain with unrecognised extra axis ''' | ||
|
||
multipointseries_domain["axes"]["composite2"] = \ | ||
multipointseries_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipointseries_domain) | ||
|
||
|
||
# TODO test coordinate identifiers of 'composite' axis | ||
# to be "x","y","z" or "x","y" | ||
# TODO test that all values in 'composite' axis are valid and consistent tuples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Pytests to test the MultiPolygon domain type in the domain.json schema file | ||
|
||
import pytest | ||
from jsonschema.exceptions import ValidationError | ||
|
||
pytestmark = pytest.mark.schema("/schemas/domain") | ||
|
||
|
||
@pytest.mark.exhaustive | ||
def test_valid_multipolygon_domain(validator, multipolygon_domain): | ||
''' Tests an example of a MultiPolygon domain ''' | ||
|
||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_missing_composite_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with missing 'composite' axis ''' | ||
|
||
del multipolygon_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_empty_composite_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with empty 'composite' axis ''' | ||
|
||
multipolygon_domain["axes"]["composite"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_wrong_composite_axis_type(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with primitive instead of polygon axis ''' | ||
|
||
multipolygon_domain["axes"]["composite"] = { | ||
"values": [1, 2, 3] | ||
} | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_wrong_composite_axis_type2(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with tuple instead of polygon axis (invalid polygons) ''' | ||
|
||
multipolygon_domain["axes"]["composite"]["values"] = [ [1, 1], [2, 2], [3, 3] ] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_wrong_data_type(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with wrong data type ''' | ||
|
||
multipolygon_domain["axes"]["composite"]["dataType"] = "tuple" | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_extra_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with unrecognised extra axis ''' | ||
|
||
multipolygon_domain["axes"]["composite2"] = \ | ||
multipolygon_domain["axes"]["composite"] | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_empty_z_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with empty 'z' axis ''' | ||
|
||
multipolygon_domain["axes"]["z"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_multivalued_z_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with multi-valued 'z' axis ''' | ||
|
||
multipolygon_domain["axes"]["z"] = { "values" : [1, 2] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_empty_t_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with empty 't' axis ''' | ||
|
||
multipolygon_domain["axes"]["t"] = { "values" : [] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
def test_multivalued_t_axis(validator, multipolygon_domain): | ||
''' Invalid: MultiPolygon domain with multi-valued 't' axis ''' | ||
|
||
multipolygon_domain["axes"]["t"] = { "values" : ["2008-01-01T04:00:00Z", "2008-01-01T05:00:00Z"] } | ||
with pytest.raises(ValidationError): | ||
validator.validate(multipolygon_domain) | ||
|
||
|
||
# TODO check coordinates are "x","y", in that order |
Oops, something went wrong.