Skip to content
Merged
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
9 changes: 6 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ jobs:
cache-dependency-path: "**/pyproject.toml"
- name: Collect schema files from aas-specs
run: |
mkdir -p ./test/adapter/schema
curl -sSLf -o ./test/adapter/schema/aasJSONSchema.json https://raw.githubusercontent.com/admin-shell-io/aas-specs-metamodel/refs/tags/${{ env.X_AAS_SPECS_RELEASE_TAG }}/schemas/json/aas.json
curl -sSLf -o ./test/adapter/schema/aasXMLSchema.xsd https://raw.githubusercontent.com/admin-shell-io/aas-specs-metamodel/refs/tags/${{ env.X_AAS_SPECS_RELEASE_TAG }}/schemas/xml/AAS.xsd
mkdir -p ./test/adapter/schemas
curl -sSLf -o ./test/adapter/schemas/aasJSONSchema.json https://raw.githubusercontent.com/admin-shell-io/aas-specs-metamodel/refs/tags/${{ env.X_AAS_SPECS_RELEASE_TAG }}/schemas/json/aas.json
curl -sSLf -o ./test/adapter/schemas/aasXMLSchema.xsd https://raw.githubusercontent.com/admin-shell-io/aas-specs-metamodel/refs/tags/${{ env.X_AAS_SPECS_RELEASE_TAG }}/schemas/xml/AAS.xsd
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -112,6 +112,9 @@ jobs:
run: |
python test/_helper/setup_testdb.py -u "admin" -p "$COUCHDB_ADMIN_PASSWORD"
- name: Test with coverage + unittest
env:
# Fail instead of silently skipping if the schema files above are missing (see test_helpers.py).
REQUIRE_SCHEMA_TESTS: "1"
run: |
python -m coverage run --source=basyx -m unittest
- name: Report test coverage
Expand Down
7 changes: 7 additions & 0 deletions sdk/test/_helper/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import base64
import configparser
import os
import os.path
import urllib.error
import urllib.request
Expand All @@ -20,6 +21,12 @@
)


# By default, the schema validation tests are skipped when the AAS schema files are missing, so that a plain local
# `python -m unittest` run doesn't require downloading them first. Set this environment variable to "1"/"true"
# (e.g. in CI) to instead make those tests fail if the files are missing, so a broken download can't silently cause
# the tests to be skipped without anyone noticing.
REQUIRE_SCHEMAS = os.environ.get("REQUIRE_SCHEMA_TESTS", "false").lower() in {"1", "true", "yes"}

# Check if CouchDB database is available. Otherwise, skip tests.
try:
request = urllib.request.Request(
Expand Down
6 changes: 6 additions & 0 deletions sdk/test/adapter/json/test_json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
)
from jsonschema import validate # type: ignore

from test._helper.test_helpers import REQUIRE_SCHEMAS

JSON_SCHEMA_FILE = os.path.join(
os.path.dirname(__file__), "../schemas/aasJSONSchema.json"
)
Expand Down Expand Up @@ -72,6 +74,10 @@ class JsonSerializationSchemaTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not os.path.exists(JSON_SCHEMA_FILE):
if REQUIRE_SCHEMAS:
raise RuntimeError(
f"REQUIRE_SCHEMA_TESTS is set, but the JSON Schema does not exist at {JSON_SCHEMA_FILE}"
)
raise unittest.SkipTest(
f"JSON Schema does not exist at {JSON_SCHEMA_FILE}, skipping test"
)
Expand Down
6 changes: 6 additions & 0 deletions sdk/test/adapter/xml/test_xml_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
)
from lxml import etree

from test._helper.test_helpers import REQUIRE_SCHEMAS

XML_SCHEMA_FILE = os.path.join(os.path.dirname(__file__), "../schemas/aasXMLSchema.xsd")


Expand Down Expand Up @@ -63,6 +65,10 @@ class XMLSerializationSchemaTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not os.path.exists(XML_SCHEMA_FILE):
if REQUIRE_SCHEMAS:
raise RuntimeError(
f"REQUIRE_SCHEMA_TESTS is set, but the XSD schema does not exist at {XML_SCHEMA_FILE}"
)
raise unittest.SkipTest(
f"XSD schema does not exist at {XML_SCHEMA_FILE}, skipping test"
)
Expand Down
Loading