From a6e6290cc88bfd5d33cf9705bc57cbb4a2916df4 Mon Sep 17 00:00:00 2001 From: Trishna Saeharaseelan <trishna.saeharaseelan@noc.ac.uk> Date: Mon, 27 Feb 2023 19:38:59 +0000 Subject: [PATCH] refactor(tests): cleanup tests --- __init__.py | 2 + examples/__init__.py | 0 .../acknowledgement.json | 2 +- .../mission_plan_AH1.json | 2 +- .../mission_plan_ECOSUB.json | 2 +- .../mission_plan_HYDROSURV.json | 8 +- .../planning_configuration.json | 2 +- examples/hydrosurv_adapter/mission_plan.json | 6 - projects/__init__.py | 0 {project => projects}/soar/SOAR_README.md | 0 {project => projects}/soar/swagger.json | 0 .../acknowledgement.json | 17 -- .../mission_plan_AH1.json | 62 ------- .../mission_plan_ECOSUB.json | 62 ------- .../mission_plan_HYDROSURV.json | 36 ---- .../planning_configuration.json | 161 ------------------ .../platform_status-from_usbl_example.json | 21 --- .../platform_status.json | 44 ----- .../ecosub_adapter/mission_plan.json | 62 ------- .../mock_data/ecosub_adapter/observation.json | 28 --- .../platform_status-from_usbl_example.json | 21 --- .../ecosub_adapter/platform_status.json | 44 ----- .../sample_decoded_ecosub_status.txt | 23 --- .../gui_adapter/planning_configuration.json | 160 ----------------- .../hydrosurv_adapter/acknowledgement.json | 17 -- .../hydrosurv_adapter/mission_plan.json | 36 ---- .../hydrosurv_adapter/platform_status.json | 30 ---- tests/test_schemas.py | 54 ++++++ 28 files changed, 61 insertions(+), 841 deletions(-) create mode 100644 examples/__init__.py create mode 100644 projects/__init__.py rename {project => projects}/soar/SOAR_README.md (100%) rename {project => projects}/soar/swagger.json (100%) delete mode 100644 tests/mock_data/autonomy_engine_adapter/acknowledgement.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/mission_plan_AH1.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/mission_plan_ECOSUB.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/mission_plan_HYDROSURV.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/planning_configuration.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/platform_status-from_usbl_example.json delete mode 100644 tests/mock_data/autonomy_engine_adapter/platform_status.json delete mode 100644 tests/mock_data/ecosub_adapter/mission_plan.json delete mode 100644 tests/mock_data/ecosub_adapter/observation.json delete mode 100644 tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json delete mode 100644 tests/mock_data/ecosub_adapter/platform_status.json delete mode 100644 tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt delete mode 100644 tests/mock_data/gui_adapter/planning_configuration.json delete mode 100644 tests/mock_data/hydrosurv_adapter/acknowledgement.json delete mode 100644 tests/mock_data/hydrosurv_adapter/mission_plan.json delete mode 100644 tests/mock_data/hydrosurv_adapter/platform_status.json diff --git a/__init__.py b/__init__.py index 42345bd..41054da 100644 --- a/__init__.py +++ b/__init__.py @@ -4,6 +4,8 @@ from flask import Flask __all__ = [ "formats", + "examples", + "projects", "tests", ] app = Flask(__name__) diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/autonomy_engine_adapter/acknowledgement.json b/examples/autonomy_engine_adapter/acknowledgement.json index 1787704..11bbc8d 100644 --- a/examples/autonomy_engine_adapter/acknowledgement.json +++ b/examples/autonomy_engine_adapter/acknowledgement.json @@ -4,7 +4,7 @@ "timestamp": "2022-11-16T00:00:00Z", "version": 1, "source": "hydrosurv_adapter", - "destination": "autonomy_engine", + "destination": "soar.#", "delivery_type": "publish", "encoded": false }, diff --git a/examples/autonomy_engine_adapter/mission_plan_AH1.json b/examples/autonomy_engine_adapter/mission_plan_AH1.json index 99d42e1..e9d96b5 100644 --- a/examples/autonomy_engine_adapter/mission_plan_AH1.json +++ b/examples/autonomy_engine_adapter/mission_plan_AH1.json @@ -4,7 +4,7 @@ "timestamp": "2022-11-16T00:00:00Z", "version": 2, "source": "autonomy_engine", - "destination": "noc_c2", + "destination": "soar.#", "delivery_type": "publish", "encoded": false }, diff --git a/examples/autonomy_engine_adapter/mission_plan_ECOSUB.json b/examples/autonomy_engine_adapter/mission_plan_ECOSUB.json index 3ba5aac..716746c 100644 --- a/examples/autonomy_engine_adapter/mission_plan_ECOSUB.json +++ b/examples/autonomy_engine_adapter/mission_plan_ECOSUB.json @@ -4,7 +4,7 @@ "timestamp": "2022-11-16T00:00:00Z", "version": 2, "source": "autonomy_engine", - "destination": "ecosub_c2", + "destination": "soar.#", "delivery_type": "publish", "encoded": false }, diff --git a/examples/autonomy_engine_adapter/mission_plan_HYDROSURV.json b/examples/autonomy_engine_adapter/mission_plan_HYDROSURV.json index 6aec0c6..18a51ce 100644 --- a/examples/autonomy_engine_adapter/mission_plan_HYDROSURV.json +++ b/examples/autonomy_engine_adapter/mission_plan_HYDROSURV.json @@ -4,7 +4,7 @@ "timestamp": "2022-11-16T00:00:00Z", "version": 2, "source": "autonomy_engine", - "destination": "hydrosurv_adapter", + "destination": "soar.#", "delivery_type": "publish", "encoded": false }, @@ -14,20 +14,14 @@ "autonomy_engine_plan_ID": 1, "plan": [ { - "start_point_latitude": -4.007143188645706, - "start_point_longitude": 50.37072283932642, "target_waypoint_latitude": -4.187143188645706, "target_waypoint_longitude": 50.37072283932642 }, { - "start_point_latitude": -4.187143188645706, - "start_point_longitude": 50.37072283932642, "target_waypoint_latitude": -3.187143188645706, "target_waypoint_longitude": 51.37072283932642 }, { - "start_point_latitude": -3.187143188645706, - "start_point_longitude": 51.37072283932642, "target_waypoint_latitude": -3.237143188645706, "target_waypoint_longitude": 52.37072283932642 } diff --git a/examples/autonomy_engine_adapter/planning_configuration.json b/examples/autonomy_engine_adapter/planning_configuration.json index 1c76fcd..f5a8281 100644 --- a/examples/autonomy_engine_adapter/planning_configuration.json +++ b/examples/autonomy_engine_adapter/planning_configuration.json @@ -4,7 +4,7 @@ "timestamp": "2022-11-16T00:00:00Z", "version": 2, "source": "ecosub_c2", - "destination": "autonomy_engine", + "destination": "soar.#", "delivery_type": "publish", "encoded": false }, diff --git a/examples/hydrosurv_adapter/mission_plan.json b/examples/hydrosurv_adapter/mission_plan.json index 6aec0c6..deff464 100644 --- a/examples/hydrosurv_adapter/mission_plan.json +++ b/examples/hydrosurv_adapter/mission_plan.json @@ -14,20 +14,14 @@ "autonomy_engine_plan_ID": 1, "plan": [ { - "start_point_latitude": -4.007143188645706, - "start_point_longitude": 50.37072283932642, "target_waypoint_latitude": -4.187143188645706, "target_waypoint_longitude": 50.37072283932642 }, { - "start_point_latitude": -4.187143188645706, - "start_point_longitude": 50.37072283932642, "target_waypoint_latitude": -3.187143188645706, "target_waypoint_longitude": 51.37072283932642 }, { - "start_point_latitude": -3.187143188645706, - "start_point_longitude": 51.37072283932642, "target_waypoint_latitude": -3.237143188645706, "target_waypoint_longitude": 52.37072283932642 } diff --git a/projects/__init__.py b/projects/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/soar/SOAR_README.md b/projects/soar/SOAR_README.md similarity index 100% rename from project/soar/SOAR_README.md rename to projects/soar/SOAR_README.md diff --git a/project/soar/swagger.json b/projects/soar/swagger.json similarity index 100% rename from project/soar/swagger.json rename to projects/soar/swagger.json diff --git a/tests/mock_data/autonomy_engine_adapter/acknowledgement.json b/tests/mock_data/autonomy_engine_adapter/acknowledgement.json deleted file mode 100644 index 1787704..0000000 --- a/tests/mock_data/autonomy_engine_adapter/acknowledgement.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 1, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "acknowledgement", - "autonomy_engine_plan_ID": 1, - "platform_ID": "reav-x-1", - "approved": false - } -} \ No newline at end of file diff --git a/tests/mock_data/autonomy_engine_adapter/mission_plan_AH1.json b/tests/mock_data/autonomy_engine_adapter/mission_plan_AH1.json deleted file mode 100644 index 99d42e1..0000000 --- a/tests/mock_data/autonomy_engine_adapter/mission_plan_AH1.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "header": { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "noc_c2", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "mission_plan", - "platform_ID": "5-ah1", - "autonomy_engine_plan_ID": 1, - "plan": [ - { - "action": "move", - "flight_style": "go to waypoint", - "start_point_latitude": -3.007143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -3.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "dive", - "flight_style": "dive to depth", - "start_point_latitude": -3.237143188645706, - "start_point_longitude": 52.37072283932642, - "target_waypoint_latitude": -3.337143188645706, - "target_waypoint_longitude": 56.37072283932642, - "altitude": 10, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "scanline", - "flight_style": "go to waypoint", - "start_point_latitude": -3.337143188645706, - "start_point_longitude": 56.37072283932642, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 60.00000000000000, - "altitude": 10, - "activate_payload": true, - "send_environmental_data": false - }, - { - "action": "climb", - "flight_style": "go to surface", - "start_point_latitude": -0.237143188645706, - "start_point_longitude": 60.00000000000000, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": true - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/autonomy_engine_adapter/mission_plan_ECOSUB.json b/tests/mock_data/autonomy_engine_adapter/mission_plan_ECOSUB.json deleted file mode 100644 index 2cfdaad..0000000 --- a/tests/mock_data/autonomy_engine_adapter/mission_plan_ECOSUB.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "header": { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "ecosub_c2", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "mission_plan", - "platform_ID": "ecosub-5", - "autonomy_engine_plan_ID": 1, - "plan": [ - { - "action": "move", - "flight_style": "go to waypoint", - "start_point_latitude": -3.007143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -3.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "dive", - "flight_style": "dive to depth", - "start_point_latitude": -3.237143188645706, - "start_point_longitude": 52.37072283932642, - "target_waypoint_latitude": -3.337143188645706, - "target_waypoint_longitude": 56.37072283932642, - "altitude": 10, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "scanline", - "flight_style": "go to waypoint", - "start_point_latitude": -3.337143188645706, - "start_point_longitude": 56.37072283932642, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 60.00000000000000, - "altitude": 10, - "activate_payload": true, - "send_environmental_data": false - }, - { - "action": "climb", - "flight_style": "go to surface", - "start_point_latitude": -0.237143188645706, - "start_point_longitude": 60.00000000000000, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": true - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/autonomy_engine_adapter/mission_plan_HYDROSURV.json b/tests/mock_data/autonomy_engine_adapter/mission_plan_HYDROSURV.json deleted file mode 100644 index 6aec0c6..0000000 --- a/tests/mock_data/autonomy_engine_adapter/mission_plan_HYDROSURV.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "hydrosurv_adapter", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "mission_plan", - "platform_ID": "reav-60-1", - "autonomy_engine_plan_ID": 1, - "plan": [ - { - "start_point_latitude": -4.007143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -4.187143188645706, - "target_waypoint_longitude": 50.37072283932642 - }, - { - "start_point_latitude": -4.187143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -3.187143188645706, - "target_waypoint_longitude": 51.37072283932642 - }, - { - "start_point_latitude": -3.187143188645706, - "start_point_longitude": 51.37072283932642, - "target_waypoint_latitude": -3.237143188645706, - "target_waypoint_longitude": 52.37072283932642 - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/autonomy_engine_adapter/planning_configuration.json b/tests/mock_data/autonomy_engine_adapter/planning_configuration.json deleted file mode 100644 index 1c76fcd..0000000 --- a/tests/mock_data/autonomy_engine_adapter/planning_configuration.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "ecosub_c2", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "planning_config_ID": 3, - "exclusion_zones": [ - { - "geometry_coordinates": [ - [ - [ - -4.187143188645706, - 50.37072283932642 - ], - [ - -4.202697005964865, - 50.368816892405874 - ], - [ - -4.203156724702808, - 50.365640144076906 - ], - [ - -4.19449868846155, - 50.362267670845654 - ] - ] - ] - } - ], - "squads": [ - { - "squad_ID": 1, - "no_of_platforms": 1, - "squad_mission_type": "tracking", - "squad_state": "active", - "platforms": [ - { - "model": "reav", - "platform_ID": "reav-60-1", - "serial": "reav-60", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -7.432, - "target_waypoint_longitude": 50.365, - "safe_command": "go_home", - "target_depth": 10.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": {} - } - ], - "region_of_interest": { - "geometry_coordinates": [ - [ - [ - -4.187143188645706, - 50.37072283932642 - ], - [ - -4.202697005964865, - 50.368816892405874 - ], - [ - -4.203156724702808, - 50.365640144076906 - ], - [ - -4.19449868846155, - 50.362267670845654 - ] - ] - ] - } - }, - { - "squad_ID": 2, - "no_of_platforms": 3, - "squad_mission_type": "survey", - "squad_state": "active", - "platforms": [ - { - "platform_ID": "ecosub-1", - "serial": "ecosub-2", - "model": "ecosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -7.432, - "target_waypoint_longitude": 50.365, - "safe_command": "go_home", - "target_depth": 10.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "DVL", - "swath_width": 10 - } - }, - { - "platform_ID": "ecosub-2", - "serial": "ecosubxyz-5", - "model": "ecosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -0.432, - "target_waypoint_longitude": 20.365, - "safe_command": "go_home", - "target_depth": 0.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "DVL", - "swath_width": 10 - } - } - ], - "region_of_interest": {} - }, - { - "squad_ID": 3, - "no_of_platforms": 1, - "squad_mission_type": "inspection", - "squad_state": "active", - "platforms": [ - { - "platform_ID": "ah-1", - "serial": "autosubhover-1", - "model": "autosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": 20.432, - "target_waypoint_longitude": 50.365, - "safe_command": "abort_now", - "target_depth": 0.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "MBES" - } - } - ], - "region_of_interest": {} - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/autonomy_engine_adapter/platform_status-from_usbl_example.json b/tests/mock_data/autonomy_engine_adapter/platform_status-from_usbl_example.json deleted file mode 100644 index 6a506d9..0000000 --- a/tests/mock_data/autonomy_engine_adapter/platform_status-from_usbl_example.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "hermes", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "platform_ID": "ecosub-5", - "platform_timestamp": "2022-12-21T00:00:00Z", - "status_source": "usbl", - "latitude": 178.2, - "longitude": -10.122, - "depth": 50.0, - "altitude": 20.0 - } -} diff --git a/tests/mock_data/autonomy_engine_adapter/platform_status.json b/tests/mock_data/autonomy_engine_adapter/platform_status.json deleted file mode 100644 index fa2ecad..0000000 --- a/tests/mock_data/autonomy_engine_adapter/platform_status.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "ecosub_c2", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "platform_ID": "ecosub-2", - "platform_timestamp": "2022-12-21T00:00:00Z", - "status_source": "onboard_platform", - "autonomy_engine_plan_ID": 1, - "battery_remaining_capacity": 80.2, - "active": true, - "platform_state": "ABORT", - "mission_plan_ID": 1, - "mission_track_ID": 4, - "latitude": 178.2, - "longitude": -10.122, - "depth": 50.0, - "altitude": 20.0, - "heading": 90.0, - "health_status": false, - "localisation_north_error": 0, - "localisation_east_error": 0, - "usbl_fix_seconds_ago": 0, - "range_to_go": 124.3, - "sensor_config": { - "sensor_ID": 22, - "serial": "sidescan-2x", - "sensor_on": true, - "additional_data": { - "whiskers_on": true - } - }, - "speed_over_ground": 4.3, - "thrust_applied": 124.3, - "water_current_velocity": "124.3NE" - } -} diff --git a/tests/mock_data/ecosub_adapter/mission_plan.json b/tests/mock_data/ecosub_adapter/mission_plan.json deleted file mode 100644 index 3ba5aac..0000000 --- a/tests/mock_data/ecosub_adapter/mission_plan.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "header": { - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "ecosub_c2", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "mission_plan", - "platform_ID": "ecosub-2", - "autonomy_engine_plan_ID": 1, - "plan": [ - { - "action": "move", - "flight_style": "go to waypoint", - "start_point_latitude": -3.007143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -3.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "dive", - "flight_style": "dive to depth", - "start_point_latitude": -3.237143188645706, - "start_point_longitude": 52.37072283932642, - "target_waypoint_latitude": -3.337143188645706, - "target_waypoint_longitude": 56.37072283932642, - "altitude": 10, - "activate_payload": false, - "send_environmental_data": false - }, - { - "action": "scanline", - "flight_style": "go to waypoint", - "start_point_latitude": -3.337143188645706, - "start_point_longitude": 56.37072283932642, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 60.00000000000000, - "altitude": 10, - "activate_payload": true, - "send_environmental_data": false - }, - { - "action": "climb", - "flight_style": "go to surface", - "start_point_latitude": -0.237143188645706, - "start_point_longitude": 60.00000000000000, - "target_waypoint_latitude": -0.237143188645706, - "target_waypoint_longitude": 52.37072283932642, - "depth": 0.0, - "activate_payload": false, - "send_environmental_data": true - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/ecosub_adapter/observation.json b/tests/mock_data/ecosub_adapter/observation.json deleted file mode 100644 index 8eb0571..0000000 --- a/tests/mock_data/ecosub_adapter/observation.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "ecosub_c2", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "observation", - "platform_ID": "ecosub-2", - "points_of_interest": [ - { - "latitude": 178.2, - "longitude": -10.122, - "quality_of_point": 0.98 - }, - { - "latitude": 50.1382, - "longitude": -11.122, - "quality_of_point": 0.50 - } - ], - "region_surveyed": "" - } -} \ No newline at end of file diff --git a/tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json b/tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json deleted file mode 100644 index 4b30009..0000000 --- a/tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "hermes", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "platform_ID": "ecosub-5", - "platform_timestamp": "2022-12-21T00:00:00Z", - "status_source": "usbl", - "latitude": 178.2, - "longitude": -10.122, - "depth": 50.0, - "altitude": 20 - } -} diff --git a/tests/mock_data/ecosub_adapter/platform_status.json b/tests/mock_data/ecosub_adapter/platform_status.json deleted file mode 100644 index 59a24f1..0000000 --- a/tests/mock_data/ecosub_adapter/platform_status.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "ecosub_c2", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "platform_ID": "ecosub-2", - "platform_timestamp": "2022-12-21T00:00:00Z", - "status_source": "onboard_platform", - "autonomy_engine_plan_ID": 1, - "battery_remaining_capacity": 80.2, - "active": true, - "platform_state": "ABORT", - "mission_plan_ID": 1, - "mission_track_ID": 4, - "latitude": 178.2, - "longitude": -10.122, - "depth": 50.0, - "altitude": 20, - "heading": 90.0, - "health_status": false, - "localisation_north_error": 0, - "localisation_east_error": 0, - "usbl_fix_seconds_ago": 0, - "range_to_go": 124.3, - "sensor_config": { - "sensor_ID": 22, - "serial": "sidescan-2x", - "sensor_on": true, - "additional_data": { - "whiskers_on": true - } - }, - "speed_over_ground": 4.3, - "thrust_applied": 124.3, - "water_current_velocity": "124.3NE" - } -} diff --git a/tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt b/tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt deleted file mode 100644 index bacf888..0000000 --- a/tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt +++ /dev/null @@ -1,23 +0,0 @@ -#C2# -4338 -(4338,) -11111111111111111000000000000000 -Health : 722 -Content_Mask : 4 -Battery Voltage : 82045 -Battery Amps : 0 -Battery Acc charge : 767 -Battery Max Amps : 548 -Battery Max Voltage : 18 -Inner pressure : 43 -Inner Temp : 4 -Inner Humidity : 0 -Max depth : 0 -Current Pitch : -80 -Max pitch : 0 -Current RPM : 0 -Surface Time : 1636015764 -last GPS Time : 0 -(b'A', 0, 60, 1636016049, 57.33663558959961, -4.444321632385254, 0, 4294934528, 722, 4, 82045, 0, 767, 548, 18, 43, 4, 0, 0, -80, 0, 0, 1636015764, 0) -['Type', 'Version', 'Sub_Num', 'Time', 'Latitude', 'Longitude', 'Health', 'Content_Mask', 'Battery Voltage', 'Battery Amps', 'Battery Acc charge', 'Battery Max Amps', 'Battery Max Voltage', 'Inner pressure', 'Inner Temp', 'Inner Humidity', 'Max depth', 'Current Pitch', 'Max pitch', 'Current RPM', 'Surface Time', 'last GPS Time'] -(b'A', 0, 60, 1636016049, 57.33663558959961, -4.444321632385254, 0, 4294934528, 722, 4, 82045, 0, 767, 548, 18, 43, 4, 0, 0, -80, 0, 0, 1636015764, 0) \ No newline at end of file diff --git a/tests/mock_data/gui_adapter/planning_configuration.json b/tests/mock_data/gui_adapter/planning_configuration.json deleted file mode 100644 index 40d1e86..0000000 --- a/tests/mock_data/gui_adapter/planning_configuration.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "ecosub_c2", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "planning_config_ID": 3, - "exclusion_zones": [ - { - "geometry_coordinates": [ - [ - [ - -4.187143188645706, - 50.37072283932642 - ], - [ - -4.202697005964865, - 50.368816892405874 - ], - [ - -4.203156724702808, - 50.365640144076906 - ], - [ - -4.19449868846155, - 50.362267670845654 - ] - ] - ] - } - ], - "squads": [ - { - "squad_ID": 1, - "no_of_platforms": 1, - "squad_mission_type": "tracking", - "squad_state": "active", - "platforms": [ - { - "model": "reav", - "platform_ID": "reav-60-1", - "serial": "reav-60", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -7.432, - "target_waypoint_longitude": 50.365, - "safe_command": "go_home", - "target_depth": 10.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": {} - } - ], - "region_of_interest": { - "geometry_coordinates": [ - [ - [ - -4.187143188645706, - 50.37072283932642 - ], - [ - -4.202697005964865, - 50.368816892405874 - ], - [ - -4.203156724702808, - 50.365640144076906 - ], - [ - -4.19449868846155, - 50.362267670845654 - ] - ] - ] - } - }, - { - "squad_ID": 2, - "no_of_platforms": 3, - "squad_mission_type": "survey", - "squad_state": "active", - "platforms": [ - { - "platform_ID": "ecosub-2", - "serial": "ecosub-2", - "model": "ecosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -7.432, - "target_waypoint_longitude": 50.365, - "safe_command": "go_home", - "target_depth": 10.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "DVL", - "swath_width": 10 - } - }, - { - "platform_ID": "ecosub-5", - "serial": "ecosub-5", - "model": "ecosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": -0.432, - "target_waypoint_longitude": 20.365, - "safe_command": "go_home", - "target_depth": 0.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "DVL", - "swath_width": 10 - } - } - ] - }, - { - "squad_ID": 3, - "no_of_platforms": 1, - "squad_mission_type": "inspection", - "squad_state": "active", - "platforms": [ - { - "platform_ID": "139-ah-1", - "serial": "ah-1", - "model": "autosub", - "emergency": { - "additional_data": {}, - "target_waypoint_latitude": 20.432, - "target_waypoint_longitude": 50.365, - "safe_command": "abort_now", - "target_depth": 0.0 - }, - "max_velocity": 0.9, - "min_altitude": 15.2, - "min_velocity": 0.1, - "additional_data": { - "scan_type": "MBES" - } - } - ], - "region_of_interest": {} - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/hydrosurv_adapter/acknowledgement.json b/tests/mock_data/hydrosurv_adapter/acknowledgement.json deleted file mode 100644 index 1787704..0000000 --- a/tests/mock_data/hydrosurv_adapter/acknowledgement.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 1, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "acknowledgement", - "autonomy_engine_plan_ID": 1, - "platform_ID": "reav-x-1", - "approved": false - } -} \ No newline at end of file diff --git a/tests/mock_data/hydrosurv_adapter/mission_plan.json b/tests/mock_data/hydrosurv_adapter/mission_plan.json deleted file mode 100644 index 6aec0c6..0000000 --- a/tests/mock_data/hydrosurv_adapter/mission_plan.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "autonomy_engine", - "destination": "hydrosurv_adapter", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "mission_plan", - "platform_ID": "reav-60-1", - "autonomy_engine_plan_ID": 1, - "plan": [ - { - "start_point_latitude": -4.007143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -4.187143188645706, - "target_waypoint_longitude": 50.37072283932642 - }, - { - "start_point_latitude": -4.187143188645706, - "start_point_longitude": 50.37072283932642, - "target_waypoint_latitude": -3.187143188645706, - "target_waypoint_longitude": 51.37072283932642 - }, - { - "start_point_latitude": -3.187143188645706, - "start_point_longitude": 51.37072283932642, - "target_waypoint_latitude": -3.237143188645706, - "target_waypoint_longitude": 52.37072283932642 - } - ] - } -} \ No newline at end of file diff --git a/tests/mock_data/hydrosurv_adapter/platform_status.json b/tests/mock_data/hydrosurv_adapter/platform_status.json deleted file mode 100644 index 4873199..0000000 --- a/tests/mock_data/hydrosurv_adapter/platform_status.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "header":{ - "message_ID": "b427003c-0000-11aa-a1eb-bvcdfghjgfdd", - "timestamp": "2022-11-16T00:00:00Z", - "version": 2, - "source": "hydrosurv_adapter", - "destination": "autonomy_engine", - "delivery_type": "publish", - "encoded": false - }, - "payload":{ - "message_type": "platform_status", - "autonomy_engine_plan_ID": 1, - "active": true, - "status_source": "onboard_platform", - "battery_remaining_capacity": 80.2, - "heading": 310.0, - "health_status": false, - "latitude": 178.2, - "longitude": -10.122, - "mission_plan_ID": 1, - "mission_track_ID": 4, - "platform_ID": "reav-60-1", - "platform_state": "ABORT", - "platform_timestamp": "2022-12-21T00:00:00Z", - "speed_over_ground": 4.5, - "range_to_go": 0.0, - "thrust_applied": 2.3 - } -} \ No newline at end of file diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 789f9ce..c893ac1 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -10,8 +10,28 @@ from tests.fixtures.schemas import ( platform_status_schema, mission_plan_schema, ) + import unittest import json +import os +from jsonschema.validators import RefResolver +from openapi_schema_validator import validate + +# class ValidateResponse: +# def __init__(self, valid, error): +# self.valid = valid +# self.error = error + +SCHEMA_DIR = "projects/soar/swagger.json" +MOCK_DATA_DIR = "examples/" + +class SchemaError(Exception): + """ + """ + def __init__(self, exception_type, message): + self.type = exception_type + self.message = message + super().__init__(self.message) class TestSpecs(unittest.TestCase): @@ -22,6 +42,40 @@ class TestSpecs(unittest.TestCase): schema, spec_url = read_from_filename("tests/fixtures/swagger.json") self.assertIsNone(openapi_v30_spec_validator.validate(schema)) +class TestAllMessageExamples(unittest.TestCase): + def test_schema_specs(self): + """ + Test specs (swagger.json generated from generate_schema_config.py) + """ + schema_ref = open(SCHEMA_DIR) + schema = json.load(schema_ref) + schema_ref.close() + + + partner_dir_list = os.listdir(MOCK_DATA_DIR) + + + for partner in partner_dir_list: + message_list = os.listdir(os.path.join(MOCK_DATA_DIR, partner)) + for message_type in message_list: + print("Testing message %s by %s now..." % (message_type, partner)) + + f = open(os.path.join(MOCK_DATA_DIR, partner, message_type)) + mock_message = json.load(f) + ref_resolver = RefResolver.from_schema(schema) + + + self.assertIsNone( + validate( + mock_message, + schema["components"]["schemas"]["MESSAGE"], + resolver=ref_resolver, + ) + ) + f.close() + + schema_ref.close() + class TestSchema(unittest.TestCase): def test_sample_hydrosurv_messages(self): -- GitLab