Skip to content

Commit

Permalink
Test wrong composite "coordinates" (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Blower <j.d.blower@reading.ac.uk>
  • Loading branch information
letmaik and Jon Blower authored Apr 24, 2022
1 parent b986422 commit ba120ca
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 31 deletions.
62 changes: 58 additions & 4 deletions schemas/domainBase.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@
"minItems" : 3,
"maxItems" : 4
}
},
"coordinates":
{
"enum":
[
["t", "x", "y", "z"],
["t", "x", "y"]
]
}
}
}
Expand Down Expand Up @@ -183,6 +191,14 @@
"minItems" : 2,
"maxItems" : 3
}
},
"coordinates":
{
"enum":
[
["x", "y", "z"],
["x", "y"]
]
}
}
}
Expand Down Expand Up @@ -223,6 +239,14 @@
"minItems" : 2,
"maxItems" : 3
}
},
"coordinates":
{
"enum":
[
["x", "y", "z"],
["x", "y"]
]
}
}
}
Expand Down Expand Up @@ -263,6 +287,10 @@
"minItems" : 3,
"maxItems" : 3
}
},
"coordinates":
{
"const": ["t", "x", "y"]
}
}
}
Expand Down Expand Up @@ -299,7 +327,8 @@
{
"$comment" : "There can only be one polygon in the axis",
"maxItems" : 1
}
},
"coordinates": { "const" : ["x", "y"] }
}
}
]
Expand Down Expand Up @@ -336,7 +365,8 @@
{
"$comment" : "There can only be one polygon in the axis",
"maxItems" : 1
}
},
"coordinates": { "const" : ["x", "y"] }
}
}
]
Expand All @@ -361,7 +391,19 @@
{
"properties" :
{
"composite" : { "$ref": "/schemas/polygonValuesAxis" },
"composite" :
{
"allOf" :
[
{ "$ref": "/schemas/polygonValuesAxis" },
{
"properties" :
{
"coordinates": { "const" : ["x", "y"] }
}
}
]
},
"z" : { "$ref" : "/schemas/numericSingleValueAxis" },
"t" : { "$ref" : "/schemas/stringSingleValueAxis" }
},
Expand All @@ -382,7 +424,19 @@
{
"properties" :
{
"composite" : { "$ref": "/schemas/polygonValuesAxis" },
"composite" :
{
"allOf" :
[
{ "$ref": "/schemas/polygonValuesAxis" },
{
"properties" :
{
"coordinates": { "const" : ["x", "y"] }
}
}
]
},
"z" : { "$ref" : "/schemas/numericSingleValueAxis" },
"t" : { "$ref" : "/schemas/stringValuesAxis" }
},
Expand Down
20 changes: 16 additions & 4 deletions test/domain_types/test_multipoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ def test_wrong_composite_axis_type(validator, multipoint_domain):
validator.validate(multipoint_domain)


def test_wrong_composite_axis_coordinates(validator, multipoint_domain):
''' Invalid: MultiPoint domain with invalid coordinates '''

multipoint_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
with pytest.raises(ValidationError):
validator.validate(multipoint_domain)


def test_wrong_composite_axis_coordinates2(validator, multipoint_domain):
''' Invalid: MultiPoint domain with invalid coordinates '''

multipoint_domain["axes"]["composite"]["coordinates"] = ["z", "y", "x"]
with pytest.raises(ValidationError):
validator.validate(multipoint_domain)


def test_extra_axis(validator, multipoint_domain):
''' Invalid: MultiPoint domain with unrecognised extra axis '''

Expand All @@ -86,7 +102,3 @@ def test_empty_t_axis(validator, multipoint_domain):
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"
18 changes: 16 additions & 2 deletions test/domain_types/test_multipointseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ def test_wrong_composite_axis_type(validator, multipointseries_domain):
validator.validate(multipointseries_domain)


def test_wrong_composite_axis_coordinates(validator, multipointseries_domain):
''' Invalid: MultiPointSeries domain with invalid coordinates '''

multipointseries_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
with pytest.raises(ValidationError):
validator.validate(multipointseries_domain)


def test_wrong_composite_axis_coordinates2(validator, multipointseries_domain):
''' Invalid: MultiPointSeries domain with invalid coordinates '''

multipointseries_domain["axes"]["composite"]["coordinates"] = ["z", "y", "x"]
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 '''

Expand Down Expand Up @@ -88,6 +104,4 @@ def test_extra_axis(validator, multipointseries_domain):
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
11 changes: 8 additions & 3 deletions test/domain_types/test_multipolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def test_empty_composite_axis(validator, multipolygon_domain):
validator.validate(multipolygon_domain)


def test_wrong_composite_axis_coordinates(validator, multipolygon_domain):
''' Invalid: MultiPolygon domain with invalid coordinates '''

multipolygon_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
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 '''

Expand Down Expand Up @@ -94,6 +102,3 @@ def test_multivalued_t_axis(validator, multipolygon_domain):
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
11 changes: 8 additions & 3 deletions test/domain_types/test_multipolygonseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def test_wrong_composite_axis_type2(validator, multipolygonseries_domain):
validator.validate(multipolygonseries_domain)


def test_wrong_composite_axis_coordinates(validator, multipolygonseries_domain):
''' Invalid: MultiPolygonSeries domain with invalid coordinates '''

multipolygonseries_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
with pytest.raises(ValidationError):
validator.validate(multipolygonseries_domain)


def test_wrong_data_type(validator, multipolygonseries_domain):
''' Invalid: MultiPolygonSeries domain with wrong data type '''

Expand Down Expand Up @@ -86,6 +94,3 @@ def test_empty_t_axis(validator, multipolygonseries_domain):
multipolygonseries_domain["axes"]["t"] = { "values" : [] }
with pytest.raises(ValidationError):
validator.validate(multipolygonseries_domain)


# TODO check coordinates are "x","y"
11 changes: 8 additions & 3 deletions test/domain_types/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def test_composite_axis_with_2_values(validator, polygon_domain):
validator.validate(polygon_domain)


def test_wrong_composite_axis_coordinates(validator, polygon_domain):
''' Invalid: Polygon domain with invalid coordinates '''

polygon_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
with pytest.raises(ValidationError):
validator.validate(polygon_domain)


def test_wrong_data_type(validator, polygon_domain):
''' Invalid: Polygon domain with wrong data type '''

Expand Down Expand Up @@ -105,6 +113,3 @@ def test_multivalued_t_axis(validator, polygon_domain):
polygon_domain["axes"]["t"] = { "values" : ["2008-01-01T04:00:00Z", "2008-01-01T05:00:00Z"] }
with pytest.raises(ValidationError):
validator.validate(polygon_domain)


# TODO check coordinates are "x","y"
11 changes: 8 additions & 3 deletions test/domain_types/test_polygonseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def test_wrong_composite_axis_type(validator, polygonseries_domain):
validator.validate(polygonseries_domain)


def test_wrong_composite_axis_coordinates(validator, polygonseries_domain):
''' Invalid: PolygonSeries domain with invalid coordinates '''

polygonseries_domain["axes"]["composite"]["coordinates"] = ["y", "x"]
with pytest.raises(ValidationError):
validator.validate(polygonseries_domain)


def test_wrong_composite_axis_type2(validator, polygonseries_domain):
''' Invalid: PolygonSeries domain with tuple instead of polygon axis (invalid polygons) '''

Expand Down Expand Up @@ -97,6 +105,3 @@ def test_empty_t_axis(validator, polygonseries_domain):
polygonseries_domain["axes"]["t"] = { "values" : [] }
with pytest.raises(ValidationError):
validator.validate(polygonseries_domain)


# TODO check coordinates are "x","y"
16 changes: 9 additions & 7 deletions test/domain_types/test_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ def test_composite_axis_with_4_values(validator, section_domain):
def test_wrong_composite_axis_type(validator, section_domain):
''' Invalid: Section domain with primitive instead of tuple axis '''

section_domain["axes"]["composite"] = {
"values": [1, 2, 3]
}
section_domain["axes"]["composite"]["values"] = [1, 2, 3]
with pytest.raises(ValidationError):
validator.validate(section_domain)


def test_wrong_composite_axis_coordinates(validator, section_domain):
''' Invalid: Section domain with invalid coordinates '''

section_domain["axes"]["composite"]["coordinates"] = ["t", "y", "x"]
with pytest.raises(ValidationError):
validator.validate(section_domain)

Expand Down Expand Up @@ -86,7 +92,3 @@ def test_empty_z_axis(validator, section_domain):
section_domain["axes"]["z"] = { "values" : [] }
with pytest.raises(ValidationError):
validator.validate(section_domain)


# TODO test coordinate identifiers of 'composite' axis
# to be "t","x","y" (can these be in another order?)
18 changes: 16 additions & 2 deletions test/domain_types/test_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ def test_wrong_composite_axis_type(validator, trajectory_domain):
validator.validate(trajectory_domain)


def test_wrong_composite_axis_coordinates(validator, trajectory_domain):
''' Invalid: Trajectory domain with invalid coordinates '''

trajectory_domain["axes"]["composite"]["coordinates"] = ["t", "y", "x"]
with pytest.raises(ValidationError):
validator.validate(trajectory_domain)


def test_wrong_composite_axis_coordinates2(validator, trajectory_domain):
''' Invalid: Trajectory domain with invalid coordinates '''

trajectory_domain["axes"]["composite"]["coordinates"] = ["t", "z", "y", "x"]
with pytest.raises(ValidationError):
validator.validate(trajectory_domain)


def test_composite_axis_with_2_values(validator, trajectory_domain):
''' Invalid: Trajectory domain with composite axis with tuples of length 2 '''

Expand Down Expand Up @@ -88,6 +104,4 @@ def test_multivalued_z_axis(validator, trajectory_domain):
validator.validate(trajectory_domain)


# TODO test coordinate identifiers of 'composite' axis
# to be "t","x","y","z" or "t","x","y"
# TODO test there cannot be both 'z' in 'composite' and a 'z' axis

0 comments on commit ba120ca

Please sign in to comment.