Skip to content

Commit

Permalink
Merge pull request #37 from NOAA-GSL/chore/idsse-473/mulit-struct-bbox
Browse files Browse the repository at this point in the history
Support bounding box "bbox" as list of list
  • Loading branch information
Geary-Layne authored Dec 8, 2023
2 parents bf0e2d9 + 1aca932 commit da4ea07
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
37 changes: 29 additions & 8 deletions python/idsse_common/idsse/common/schema/das_web_request.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
{
"BBoxObj": {
"type": "object",
"properties": {
"botLeft": {"type": "array", "items": {"type": "integer"}, "minItems": 2, "maxItems": 2},
"topRight": {"type": "array", "items": {"type": "integer"}, "minItems": 2, "maxItems": 2}
},
"required": [
"botLeft",
"topRight"
]
},

"BBoxList": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 2,
"maxItems": 2
},
"minItems": 2,
"maxItems": 2
},

"DasWebRequest": {
"description": "Mechanism for defining DAS data request via the web api",
"type": "object",
Expand All @@ -14,14 +40,9 @@
"minItems": 1
},
"bbox": {
"type": "object",
"properties": {
"botLeft": {"type": "array", "items": {"type": "integer"}, "minItems": 2, "maxItems": 2},
"topRight": {"type": "array", "items": {"type": "integer"}, "minItems": 2, "maxItems": 2}
},
"required": [
"botLeft",
"topRight"
"oneOf": [
{"$ref": "#/BBoxObj"},
{"$ref": "#/BBoxList"}
]
}
},
Expand Down
26 changes: 24 additions & 2 deletions python/idsse_common/test/test_validate_das_web_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,30 @@ def test_validate_das_web_request_message(das_web_request_validator: Validator,
assert False, f'Validate message raised an exception {exc}'


def test_validate_das_web_request_message_bad_bbox(das_web_request_validator: Validator,
das_web_request_message: dict):
def test_validate_das_web_request_message_with_bbox_list(das_web_request_validator: Validator,
das_web_request_message: dict):
bbox = das_web_request_message.pop('bbox')
das_web_request_message['bbox'] = [bbox['botLeft'], bbox['topRight']]
try:
das_web_request_validator.validate(das_web_request_message)
except ValidationError as exc:
assert False, f'Validate message raised an exception {exc}'


def test_validate_das_web_request_message_bad_bbox_list(das_web_request_validator: Validator,
das_web_request_message: dict):
bbox = das_web_request_message.pop('bbox')
bot_left = bbox['botLeft']
top_right = bbox['topRight']
# move one value from bottom and adding to top, making neither represent a coordinate
top_right.append(bot_left.pop(1))
das_web_request_message['bbox'] = [bot_left, top_right]
with raises(ValidationError):
das_web_request_validator.validate(das_web_request_message)


def test_validate_das_web_request_message_bad_bbox_obj(das_web_request_validator: Validator,
das_web_request_message: dict):
# replace the bottom left int coordinate with a float
das_web_request_message['bbox']['botLeft'][0] = 1.2
with raises(ValidationError):
Expand Down

0 comments on commit da4ea07

Please sign in to comment.