Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
url: file://./test_data/che/geoawareness/cis_source_sample_ed269.json
source_document_ed318:
resource_type: resources.eurocae.ed318.source_document.SourceDocument
specification:
url: file://./test_data/che/geoawareness/cis_source_sample_ed318.json
source_schema_ed318_geozones:
resource_type: resources.eurocae.ed318.source_schema.SourceSchema
specification:
url: file://./test_data/che/geoawareness/flattened_schema.json
Comment on lines +14 to +17
Copy link
Copy Markdown
Contributor

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.

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:
Expand Down
Empty file.
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 monitoring/uss_qualifier/resources/eurocae/ed318/source_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from implicitdict import ImplicitDict
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.
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.
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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the jsonschema documentation, this throws a jsonschema.exceptions.ValidationError

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 monitoring/uss_qualifier/suites/uspace/geo_awareness_cis.yaml
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
Loading
Loading