Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-message-format
Commits
a6e6290c
Commit
a6e6290c
authored
2 years ago
by
Trishna Saeharaseelan
Browse files
Options
Download
Email Patches
Plain Diff
refactor(tests): cleanup tests
parent
50676c6d
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
331 deletions
+54
-331
tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json
...ata/ecosub_adapter/platform_status-from_usbl_example.json
+0
-21
tests/mock_data/ecosub_adapter/platform_status.json
tests/mock_data/ecosub_adapter/platform_status.json
+0
-44
tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt
...mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt
+0
-23
tests/mock_data/gui_adapter/planning_configuration.json
tests/mock_data/gui_adapter/planning_configuration.json
+0
-160
tests/mock_data/hydrosurv_adapter/acknowledgement.json
tests/mock_data/hydrosurv_adapter/acknowledgement.json
+0
-17
tests/mock_data/hydrosurv_adapter/mission_plan.json
tests/mock_data/hydrosurv_adapter/mission_plan.json
+0
-36
tests/mock_data/hydrosurv_adapter/platform_status.json
tests/mock_data/hydrosurv_adapter/platform_status.json
+0
-30
tests/test_schemas.py
tests/test_schemas.py
+54
-0
No files found.
tests/mock_data/ecosub_adapter/platform_status-from_usbl_example.json
deleted
100644 → 0
View file @
50676c6d
{
"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
}
}
This diff is collapsed.
Click to expand it.
tests/mock_data/ecosub_adapter/platform_status.json
deleted
100644 → 0
View file @
50676c6d
{
"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"
}
}
This diff is collapsed.
Click to expand it.
tests/mock_data/ecosub_adapter/sample_decoded_ecosub_status.txt
deleted
100644 → 0
View file @
50676c6d
#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
This diff is collapsed.
Click to expand it.
tests/mock_data/gui_adapter/planning_configuration.json
deleted
100644 → 0
View file @
50676c6d
{
"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
This diff is collapsed.
Click to expand it.
tests/mock_data/hydrosurv_adapter/acknowledgement.json
deleted
100644 → 0
View file @
50676c6d
{
"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
This diff is collapsed.
Click to expand it.
tests/mock_data/hydrosurv_adapter/mission_plan.json
deleted
100644 → 0
View file @
50676c6d
{
"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
This diff is collapsed.
Click to expand it.
tests/mock_data/hydrosurv_adapter/platform_status.json
deleted
100644 → 0
View file @
50676c6d
{
"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
This diff is collapsed.
Click to expand it.
tests/test_schemas.py
View file @
a6e6290c
...
@@ -10,8 +10,28 @@ from tests.fixtures.schemas import (
...
@@ -10,8 +10,28 @@ from tests.fixtures.schemas import (
platform_status_schema
,
platform_status_schema
,
mission_plan_schema
,
mission_plan_schema
,
)
)
import
unittest
import
unittest
import
json
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
):
class
TestSpecs
(
unittest
.
TestCase
):
...
@@ -22,6 +42,40 @@ class TestSpecs(unittest.TestCase):
...
@@ -22,6 +42,40 @@ class TestSpecs(unittest.TestCase):
schema
,
spec_url
=
read_from_filename
(
"tests/fixtures/swagger.json"
)
schema
,
spec_url
=
read_from_filename
(
"tests/fixtures/swagger.json"
)
self
.
assertIsNone
(
openapi_v30_spec_validator
.
validate
(
schema
))
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
):
class
TestSchema
(
unittest
.
TestCase
):
def
test_sample_hydrosurv_messages
(
self
):
def
test_sample_hydrosurv_messages
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment