From 1aca9327ca4b7f331f7a94673909b9c676125b97 Mon Sep 17 00:00:00 2001 From: Geary Layne Date: Wed, 29 Nov 2023 06:40:46 -0700 Subject: [PATCH] updated bbox list schema --- .../idsse/common/schema/das_web_request.json | 8 ++++++-- .../test/test_validate_das_web_schema.py | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/python/idsse_common/idsse/common/schema/das_web_request.json b/python/idsse_common/idsse/common/schema/das_web_request.json index e59d0011..7d7ad955 100644 --- a/python/idsse_common/idsse/common/schema/das_web_request.json +++ b/python/idsse_common/idsse/common/schema/das_web_request.json @@ -17,8 +17,12 @@ "type": "array", "items": { "type": "integer" - } - } + }, + "minItems": 2, + "maxItems": 2 + }, + "minItems": 2, + "maxItems": 2 }, "DasWebRequest": { diff --git a/python/idsse_common/test/test_validate_das_web_schema.py b/python/idsse_common/test/test_validate_das_web_schema.py index e8fecdc9..f06ea151 100644 --- a/python/idsse_common/test/test_validate_das_web_schema.py +++ b/python/idsse_common/test/test_validate_das_web_schema.py @@ -147,8 +147,8 @@ 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_with_bbox_as_list(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: @@ -157,8 +157,20 @@ def test_validate_das_web_request_message_with_bbox_as_list(das_web_request_vali 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_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):