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
1ac5df20
Commit
1ac5df20
authored
2 years ago
by
Trishna Saeharaseelan
Browse files
Options
Download
Email Patches
Plain Diff
fix: lint & black
parent
ef3194b2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
36 deletions
+113
-36
formats/mission_plan.py
formats/mission_plan.py
+6
-1
formats/platform_status.py
formats/platform_status.py
+2
-2
generate_schema_config.py
generate_schema_config.py
+10
-7
tests/fixtures/schemas.py
tests/fixtures/schemas.py
+7
-2
tests/test_schemas.py
tests/test_schemas.py
+88
-24
No files found.
formats/mission_plan.py
View file @
1ac5df20
...
...
@@ -86,5 +86,10 @@ mission_plan_schema = {
"items"
:
action_schema
,
},
},
"required"
:
[
"message_type"
,
"autonomy_engine_plan_ID"
,
"platform_ID"
,
"plan"
],
"required"
:
[
"message_type"
,
"autonomy_engine_plan_ID"
,
"platform_ID"
,
"plan"
,
],
}
This diff is collapsed.
Click to expand it.
formats/platform_status.py
View file @
1ac5df20
...
...
@@ -59,11 +59,11 @@ platform_status_schema = {
"example"
:
"2022-12-21T00:00:00Z"
,
},
"platform_state"
:
{
"type"
:
"string"
,
# TODO: Define enum with potential STATES of each platform
"type"
:
"string"
,
"description"
:
"Current state executed by platform. E.g. "
+
"STOP, IDLE, ABORT."
,
"example"
:
"ABORT"
,
},
},
# TODO: Define enum with potential STATES of each platform
"autonomy_engine_plan_ID"
:
{
"type"
:
"integer"
,
"description"
:
"Last mission plan ID (according to Autonomy"
...
...
This diff is collapsed.
Click to expand it.
generate_schema_config.py
View file @
1ac5df20
...
...
@@ -31,7 +31,9 @@ swagger_config = {
"schemas"
:
{
"MESSAGE"
:
{
"type"
:
"object"
,
"description"
:
"Full message definition with message-metadata in `header` and different message type schemas under `payload`"
,
"description"
:
"Full message definition with"
+
" message-metadata in `header` and different"
+
" message type schemas under `payload`"
,
"properties"
:
{
"header"
:
{
"$ref"
:
"#/components/schemas/header"
,
...
...
@@ -46,17 +48,18 @@ swagger_config = {
"mapping"
:
{
"mission_plan"
:
"#/components/schemas/mission_plan"
,
"observation"
:
"#/components/schemas/observation"
,
"planning_configuration"
:
"#/components/schemas/planning_configuration"
,
"planning_configuration"
:
"#/components/schemas/"
+
"planning_configuration"
,
"platform_status"
:
"#/components/schemas/platform_status"
,
"acknowledgement"
:
"#/components/schemas/acknowledgement"
,
},
},
"oneOf"
:
[
{
"$ref"
:
"#/components/schemas/
"
+
"
acknowledgement"
},
{
"$ref"
:
"#/components/schemas/
"
+
"
mission_plan"
},
{
"$ref"
:
"#/components/schemas/
"
+
"
observation"
},
{
"$ref"
:
"#/components/schemas/
"
+
"
planning_configuration"
},
{
"$ref"
:
"#/components/schemas/
"
+
"
platform_status"
},
{
"$ref"
:
"#/components/schemas/acknowledgement"
},
{
"$ref"
:
"#/components/schemas/mission_plan"
},
{
"$ref"
:
"#/components/schemas/observation"
},
{
"$ref"
:
"#/components/schemas/planning_configuration"
},
{
"$ref"
:
"#/components/schemas/platform_status"
},
],
},
"header"
:
message_header
,
...
...
This diff is collapsed.
Click to expand it.
tests/fixtures/schemas.py
View file @
1ac5df20
...
...
@@ -158,7 +158,12 @@ mission_plan_schema = {
"items"
:
action_schema
,
},
},
"required"
:
[
"message_type"
,
"autonomy_engine_plan_ID"
,
"platform_ID"
,
"plan"
],
"required"
:
[
"message_type"
,
"autonomy_engine_plan_ID"
,
"platform_ID"
,
"plan"
,
],
}
...
...
@@ -460,7 +465,7 @@ platform_status_schema = {
"example"
:
"2022-12-21T00:00:00Z"
,
},
"platform_state"
:
{
"type"
:
"string"
,
# TODO: Define enum with potential STATES of each platform
"type"
:
"string"
,
"description"
:
"Current state executed by platform. E.g. "
+
"STOP, IDLE, ABORT."
,
"example"
:
"ABORT"
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_schemas.py
View file @
1ac5df20
from
openapi_spec_validator
import
openapi_v30_spec_validator
,
openapi_v3_spec_validator
from
openapi_spec_validator
import
openapi_v30_spec_validator
from
openapi_spec_validator.readers
import
read_from_filename
from
openapi_schema_validator
import
validate
from
jsonschema
import
FormatChecker
from
jsonschema
import
validate
import
unittest
from
tests.fixtures.schemas
import
(
acknowledgement_schema
,
message_header
,
...
...
@@ -14,6 +10,7 @@ from tests.fixtures.schemas import (
platform_status_schema
,
mission_plan_schema
,
)
import
unittest
import
json
...
...
@@ -37,21 +34,35 @@ class TestSchema(unittest.TestCase):
mock_data
=
json
.
load
(
f
)
header_data
=
mock_data
[
"header"
]
payload_data
=
mock_data
[
"payload"
]
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
()))
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
(),
)
)
if
item
==
"acknowledgement"
:
self
.
assertIsNone
(
validate
(
payload_data
,
acknowledgement_schema
,
format_checker
=
FormatChecker
()
payload_data
,
acknowledgement_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"mission_plan"
:
self
.
assertIsNone
(
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"platform_status"
:
self
.
assertIsNone
(
validate
(
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
()
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
(),
)
)
...
...
@@ -65,7 +76,13 @@ class TestSchema(unittest.TestCase):
mock_data
=
json
.
load
(
f
)
header_data
=
mock_data
[
"header"
]
payload_data
=
mock_data
[
"payload"
]
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
()))
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
(),
)
)
if
item
==
"planning_configuration"
:
self
.
assertIsNone
(
validate
(
...
...
@@ -90,26 +107,44 @@ class TestSchema(unittest.TestCase):
mock_data
=
json
.
load
(
f
)
header_data
=
mock_data
[
"header"
]
payload_data
=
mock_data
[
"payload"
]
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
()))
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
(),
)
)
if
item
==
"platform_status-from_usbl_example.json"
:
self
.
assertIsNone
(
validate
(
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
()
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"mission_plan"
:
self
.
assertIsNone
(
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"platform_status"
:
self
.
assertIsNone
(
validate
(
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
()
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"observation"
:
self
.
assertIsNone
(
validate
(
payload_data
,
observation_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
observation_schema
,
format_checker
=
FormatChecker
(),
)
)
def
test_sample_autonomy_engine_messages
(
self
):
...
...
@@ -130,34 +165,60 @@ class TestSchema(unittest.TestCase):
mock_data
=
json
.
load
(
f
)
header_data
=
mock_data
[
"header"
]
payload_data
=
mock_data
[
"payload"
]
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
()))
self
.
assertIsNone
(
validate
(
header_data
,
message_header
,
format_checker
=
FormatChecker
(),
)
)
if
item
==
"platform_status-from_usbl_example.json"
:
self
.
assertIsNone
(
validate
(
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
()
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"mission_plan_AH1"
:
self
.
assertIsNone
(
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"mission_plan_ECOSUB"
:
self
.
assertIsNone
(
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"mission_plan_HYDROSURV"
:
self
.
assertIsNone
(
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
mission_plan_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"platform_status"
:
self
.
assertIsNone
(
validate
(
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
()
payload_data
,
platform_status_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"observation"
:
self
.
assertIsNone
(
validate
(
payload_data
,
observation_schema
,
format_checker
=
FormatChecker
())
validate
(
payload_data
,
observation_schema
,
format_checker
=
FormatChecker
(),
)
)
elif
item
==
"planning_configuration"
:
self
.
assertIsNone
(
...
...
@@ -170,9 +231,12 @@ class TestSchema(unittest.TestCase):
elif
item
==
"acknowledgement"
:
self
.
assertIsNone
(
validate
(
payload_data
,
acknowledgement_schema
,
format_checker
=
FormatChecker
()
payload_data
,
acknowledgement_schema
,
format_checker
=
FormatChecker
(),
)
)
if
__name__
==
'__main__'
:
if
__name__
==
"__main__"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
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