-
Notifications
You must be signed in to change notification settings - Fork 31
[uss_qualifier] Add ed318 test scenario #1438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
raphaelcere
wants to merge
6
commits into
interuss:main
Choose a base branch
from
swiss-foca:ed318-doc-3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7be2180
initial copy ED-318
raphaelcere 2d8eda1
cleaning
raphaelcere 55816ca
Update monitoring/uss_qualifier/scenarios/eurocae/ed318/source_data_m…
raphaelcere a8c122a
Update monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml
raphaelcere f700503
Update monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml
raphaelcere efaf1c5
Update monitoring/uss_qualifier/scenarios/eurocae/ed318/source_data_m…
raphaelcere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
23 changes: 23 additions & 0 deletions
23
monitoring/uss_qualifier/resources/eurocae/ed318/source_document.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from implicitdict import ImplicitDict | ||
|
|
||
| from monitoring.uss_qualifier import fileio | ||
| from monitoring.uss_qualifier.resources.resource import Resource | ||
|
|
||
|
|
||
| class SourceDocumentSpecification(ImplicitDict): | ||
| url: str | ||
| """Url of the ED-318 document to verify""" | ||
|
|
||
|
|
||
| class SourceDocument(Resource[SourceDocumentSpecification]): | ||
| specification: SourceDocumentSpecification | ||
|
|
||
| raw_document: str | ||
| """Content of the document""" | ||
|
|
||
| def __init__( | ||
| self, specification: SourceDocumentSpecification, resource_origin: str | ||
| ): | ||
| super(SourceDocument, self).__init__(specification, resource_origin) | ||
| self.specification = specification | ||
| self.raw_document = fileio.load_content(specification.url) |
22 changes: 22 additions & 0 deletions
22
monitoring/uss_qualifier/resources/eurocae/ed318/source_schema.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from implicitdict import ImplicitDict | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File to be removed |
||
|
|
||
| from monitoring.uss_qualifier import fileio | ||
| from monitoring.uss_qualifier.resources.resource import Resource | ||
|
|
||
| class SourceSchemaSpecification(ImplicitDict): | ||
| url: str | ||
| """Url of the ED-318 schema to verify""" | ||
|
|
||
|
|
||
| class SourceSchema(Resource[SourceSchemaSpecification]): | ||
| specification: SourceSchemaSpecification | ||
|
|
||
| raw_schema: str | ||
| """Content of the schema""" | ||
|
|
||
| def __init__( | ||
| self, specification: SourceSchemaSpecification, resource_origin: str | ||
| ): | ||
| super(SourceSchema, self).__init__(specification, resource_origin) | ||
| self.specification = specification | ||
| self.raw_schema = fileio.load_content(specification.url) | ||
Empty file.
23 changes: 23 additions & 0 deletions
23
monitoring/uss_qualifier/scenarios/eurocae/ed318/source_data_model.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # EUROCAE ED-318 UAS geographical zone model test scenario | ||
|
|
||
| ## Overview | ||
|
|
||
| This scenario verifies that a JSON document complies with the ED-318 UAS Geographical Zone Model for Geo-Awareness purpose. | ||
|
|
||
| ## Resources | ||
|
|
||
| ### source_document | ||
|
|
||
| The file or url of the document to be tested. | ||
|
|
||
| ## ED-318 data model compliance test case | ||
|
|
||
| ### Valid source test step | ||
|
|
||
| #### 🛑 Valid JSON check | ||
|
|
||
| The JSON file is properly formatted and can be read successfully. | ||
|
|
||
| #### 🛑 Valid schema and values check | ||
|
|
||
| The file respects the ED-318 schema and values are valid. |
79 changes: 79 additions & 0 deletions
79
monitoring/uss_qualifier/scenarios/eurocae/ed318/source_data_model.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import json | ||
| from typing import List | ||
| from jsonschema import validate | ||
|
|
||
| from implicitdict import ImplicitDict, StringBasedDateTime | ||
|
|
||
| from monitoring.uss_qualifier.resources.eurocae.ed318.source_document import ( | ||
| SourceDocument, | ||
| ) | ||
| from monitoring.uss_qualifier.resources.eurocae.ed318.source_schema import ( | ||
| SourceSchema, | ||
| ) | ||
| from monitoring.uss_qualifier.scenarios.scenario import TestScenario | ||
| from monitoring.uss_qualifier.suites.suite import ExecutionContext | ||
|
|
||
|
|
||
| class SourceDataModelValidation(TestScenario): | ||
| source_document: SourceDocument | ||
| source_schema: SourceSchema | ||
|
|
||
| def __init__(self, source_document: SourceDocument, source_schema: SourceSchema): | ||
| super().__init__() | ||
| self.source_document = source_document | ||
| self.source_schema = source_schema | ||
|
|
||
| def run(self, context: ExecutionContext): | ||
| self.begin_test_scenario(context) | ||
|
|
||
| self.record_note( | ||
| "Document", | ||
| f"Ready at {self.source_document.specification.url}", | ||
| ) | ||
| self.record_note( | ||
| "Schema", | ||
| f"Ready at {self.source_schema.specification.url}", | ||
| ) | ||
|
|
||
| self.begin_test_case("ED-318 data model compliance") | ||
| self.begin_test_step("Valid source") | ||
|
|
||
| data = None | ||
| with self.check( | ||
| "Valid JSON", [self.source_document.specification.url], | ||
| ) as check: | ||
| try: | ||
| data = json.loads(self.source_document.raw_document) | ||
| except json.decoder.JSONDecodeError as e: | ||
| check.record_failed( | ||
| summary="Unable to deserialize the document as JSON", | ||
| details=str(e), | ||
| ) | ||
|
|
||
| schema = None | ||
| with self.check( | ||
| "Valid JSON", [self.source_schema.specification.url], | ||
| ) as check: | ||
| try: | ||
| schema = json.loads(self.source_schema.raw_schema) | ||
| except json.decoder.JSONDecodeError as e: | ||
| check.record_failed( | ||
| summary="Unable to deserialize the document as JSON", | ||
| details=str(e), | ||
| ) | ||
|
|
||
| if data and schema: | ||
| with self.check( | ||
| "Valid schema and values", [self.source_document.specification.url] | ||
| ) as check: | ||
| try: | ||
| validate(instance=data, schema=schema) | ||
| except ValueError as e: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the |
||
| check.record_failed( | ||
| summary="Invalid format error", | ||
| details=str(e), | ||
| ) | ||
|
|
||
| self.end_test_step() | ||
| self.end_test_case() | ||
| self.end_test_scenario() | ||
12 changes: 10 additions & 2 deletions
12
monitoring/uss_qualifier/suites/uspace/geo_awareness_cis.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,17 @@ | ||
| name: U-Space Common Information Service | ||
| resources: | ||
| source_document: resources.eurocae.ed269.source_document.SourceDocument | ||
| source_document_ed269: resources.eurocae.ed269.source_document.SourceDocument | ||
| source_document_ed318: resources.eurocae.ed318.source_document.SourceDocument | ||
| source_schema_ed318_geozones: resources.eurocae.ed318.source_schema.SourceSchema | ||
| actions: | ||
| - test_scenario: | ||
| scenario_type: scenarios.eurocae.ed269.source_data_model.SourceDataModelValidation | ||
| resources: | ||
| source_document: source_document | ||
| source_document: source_document_ed269 | ||
| on_failure: Abort | ||
| - test_scenario: | ||
| scenario_type: scenarios.eurocae.ed318.source_data_model.SourceDataModelValidation | ||
| resources: | ||
| source_document: source_document_ed318 | ||
| source_schema: source_schema_ed318_geozones | ||
| on_failure: Abort |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ed318 schema should be somehow sourced in the repo (most likely through a submodule of the source-of-truth ed318 repo if that is possible) rather than a resource passed to the scenario.