-
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
7be2180
2d8eda1
55816ca
a8c122a
f700503
efaf1c5
799bcf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,15 +3,25 @@ v1: | |
| test_run: | ||
| resources: | ||
| resource_declarations: | ||
| source_document: | ||
| source_document_ed269: | ||
| resource_type: resources.eurocae.ed269.source_document.SourceDocument | ||
| specification: | ||
| url: file://./test_data/che/geoawareness/cis_source_sample.json | ||
| source_document_ed318: | ||
| resource_type: resources.eurocae.ed318.source_document.SourceDocument | ||
| specification: | ||
| url: file://./test_data/che/geoawareness/SwissGeozones_ED318_Testdaten.json | ||
|
raphaelcere marked this conversation as resolved.
Outdated
|
||
| source_schema_ed318_geozones: | ||
| resource_type: resources.eurocae.ed318.source_schema.SourceSchema | ||
| specification: | ||
| url: file://./test_data/che/geoawareness/flattened_schema.json | ||
|
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. 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. |
||
| action: | ||
| test_suite: | ||
| suite_type: suites.uspace.geo_awareness_cis | ||
| resources: | ||
| source_document: source_document | ||
| source_document_ed269: source_document_ed269 | ||
| source_document_ed318: source_document_ed318 | ||
| source_schema_ed318_geozones: source_schema_ed318_geozones | ||
| execution: | ||
| stop_fast: true | ||
| artifacts: | ||
|
|
||
| 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) |
| 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # 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. | ||
|
|
||
| ### source_schema | ||
|
|
||
| The file or url of the schema to be tested. | ||
|
|
||
|
raphaelcere marked this conversation as resolved.
Outdated
|
||
| ## 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import json | ||
| from typing import List | ||
| from jsonschema import validate | ||
|
|
||
| from implicitdict import ImplicitDict, StringBasedDateTime | ||
|
|
||
| # from uas_standards.eurocae_ed318 import UASZoneVersion | ||
|
|
||
|
raphaelcere marked this conversation as resolved.
Outdated
|
||
| 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() | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.