-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
208 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,66 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import subprocess | ||
from typing import List, Optional | ||
from tempfile import NamedTemporaryFile, TemporaryDirectory | ||
from dataclasses import dataclass | ||
|
||
DISABLE_CHECK = "<!-- no-check -->" | ||
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) | ||
README = os.path.join(ROOT_DIR, 'README.md') | ||
|
||
print(f"Checking {README}") | ||
|
||
with open(README) as f: | ||
lines = f.readlines() | ||
|
||
|
||
@dataclass | ||
class Block: | ||
lang: str | ||
check: bool | ||
content: str = "" | ||
|
||
|
||
blocks: List[Block] = [] | ||
|
||
last_block: Optional[Block] = None | ||
check_next = True | ||
for line in lines: | ||
if line.startswith("```"): | ||
if last_block is None: | ||
last_block = Block(line[3:].strip(), check_next) | ||
check_next = True | ||
else: | ||
blocks.append(last_block) | ||
last_block = None | ||
elif line.startswith(DISABLE_CHECK): | ||
if last_block: | ||
raise Exception(f"Found '{DISABLE_CHECK}' within block") | ||
else: | ||
check_next = False | ||
else: | ||
if last_block is not None: | ||
last_block.content += line | ||
|
||
print(f"Found {len(blocks)} code blocks:") | ||
|
||
with TemporaryDirectory() as tmp_dir: | ||
# Create these files as some snippets rely on them | ||
open(os.path.join(tmp_dir, "aas.aasx"), "w") | ||
open(os.path.join(tmp_dir, "aas.json"), "w") | ||
open(os.path.join(tmp_dir, "aas.xml"), "w") | ||
|
||
skipped = 0 | ||
for block in blocks: | ||
if not block.check: | ||
skipped += 1 | ||
continue | ||
with NamedTemporaryFile(mode="w") as f: | ||
print("-"*10) | ||
print(block.content) | ||
print("-"*10) | ||
f.write(block.content) | ||
f.flush() | ||
subprocess.check_call(["python", f.name], env={**os.environ, 'PYTHONPATH': ROOT_DIR}, cwd=tmp_dir) |
This file contains 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
This file contains 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,43 @@ | ||
# API Tests | ||
|
||
The following sections list all special conditions when checking an AAS REST API. | ||
Please note, that in case of checking responses, the conditions described [here](file.md) apply, too. | ||
|
||
## Query Parameters | ||
|
||
Validation around duplicate query parameters is not in the scope of test-engine. | ||
See https://github.com/admin-shell-io/aas-specs-api/issues/313 for details. | ||
|
||
## Operations | ||
|
||
Methods like `InvokeOperation` are not executed as we cannot check their side-effects in a generic way | ||
|
||
## Non-Applicability of Serialization Modifiers | ||
|
||
In Part 2, Section 11.3 "Applicability of SerializationModifiers" it is not specified what Applicability means in the context of HTTP/REST. | ||
For current scope/release, the test-engine expects below behavior: | ||
|
||
**For level and extent:** | ||
A server should not throw any error for not applicable query parameters, i.e., Level and Extent. The server should in this case, ignore the query parameters and return the serialization of the element. | ||
|
||
**For content:** | ||
The server should result in an error, usually 404. | ||
|
||
See https://github.com/admin-shell-io/aas-specs-api/issues/327 for details. | ||
|
||
## GetAllSubmodelElements | ||
|
||
`/submodel-elements` is under-specified for the different SerializationModifiers. | ||
See the following issues for details: | ||
* https://github.com/admin-shell-io/aas-specs-api/issues/265 | ||
* https://github.com/admin-shell-io/aas-specs-api/issues/185 | ||
* https://github.com/admin-shell-io/aas-specs-api/issues/246 | ||
|
||
## Pagination | ||
|
||
It is possible that the server is modified during the pagination request. However, the specifications are underdefines for such scenario. | ||
Thus, for the current scope of the test-engine, modification around pagination is not being considered. | ||
|
||
Cursor has to be serialized as string, even though it is an integer. No other data type is allowed. | ||
As the specification allows the cursor in the response to be both Base64UrlEncoded as well as not-encoded, the test-engine supports both. | ||
|
This file contains 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,15 @@ | ||
# File Tests | ||
|
||
The following sections list all special conditions when checking an AAS file. | ||
|
||
## Constraints | ||
|
||
All constraints of Part 1 and Part 3a are checked except for the following: | ||
* AASd-012 | ||
* AASd-115 | ||
* AASd-020 | ||
* AASd-021 | ||
* AASd-022 | ||
* AASd-077 | ||
* AASc-3a-003 | ||
* AASc-3a-050 |