-
Notifications
You must be signed in to change notification settings - Fork 27
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
6 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/service-integration/src/service_integration/commands/validate.py
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,7 @@ | ||
# .osparc folder | ||
# | ||
|
||
|
||
# | ||
# test_validation_data_follows_definition: | ||
# |
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 @@ | ||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=unused-argument | ||
# pylint: disable=unused-variable | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
pytest_plugins = [ | ||
"service_integration.pytest_plugin.folder_structure", | ||
"service_integration.pytest_plugin.validation_data", | ||
"service_integration.pytest_plugin.docker_integration", | ||
] | ||
|
||
|
||
current_dir = Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent |
15 changes: 15 additions & 0 deletions
15
packages/service-integration/tests_service/integration/test_docker_container.py
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 @@ | ||
# pylint:disable=unused-variable | ||
# pylint:disable=unused-argument | ||
# pylint:disable=redefined-outer-name | ||
|
||
|
||
import docker | ||
from service_integration.pytest_plugin.docker_integration import assert_container_runs | ||
|
||
|
||
def test_run_container( | ||
validation_folders: dict, | ||
host_folders: dict, | ||
docker_container: docker.models.containers.Container, | ||
): | ||
assert_container_runs(validation_folders, host_folders, docker_container) |
24 changes: 24 additions & 0 deletions
24
packages/service-integration/tests_service/integration/test_docker_image.py
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,24 @@ | ||
# pylint:disable=unused-variable | ||
# pylint:disable=unused-argument | ||
# pylint:disable=redefined-outer-name | ||
|
||
|
||
import docker | ||
from service_integration.pytest_plugin.docker_integration import ( | ||
assert_docker_io_simcore_labels_against_files, | ||
assert_validate_docker_io_simcore_labels, | ||
) | ||
|
||
|
||
def test_docker_io_simcore_labels_against_files( | ||
docker_image: docker.models.images.Image, metadata_labels: dict | ||
): | ||
assert_docker_io_simcore_labels_against_files(docker_image, metadata_labels) | ||
|
||
|
||
def test_validate_docker_io_simcore_labels( | ||
docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: dict | ||
): | ||
assert_validate_docker_io_simcore_labels( | ||
docker_image, osparc_service_labels_jsonschema | ||
) |
18 changes: 18 additions & 0 deletions
18
packages/service-integration/tests_service/unit/test_folder_structure.py
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,18 @@ | ||
# pylint:disable=unused-variable | ||
# pylint:disable=unused-argument | ||
# pylint:disable=redefined-outer-name | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
from service_integration.pytest_plugin.folder_structure import ( | ||
assert_path_in_repo, | ||
get_expected_files, | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"expected_path", get_expected_files("{{ cookiecutter.docker_base.split(':')[0] }}") | ||
) | ||
def test_path_in_repo(expected_path: str, project_slug_dir: Path): | ||
assert_path_in_repo(expected_path, project_slug_dir) |
44 changes: 44 additions & 0 deletions
44
packages/service-integration/tests_service/unit/test_validation_data.py
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,44 @@ | ||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=unused-argument | ||
# pylint: disable=unused-variable | ||
|
||
from pathlib import Path | ||
|
||
|
||
def test_validation_data_follows_definition( | ||
label_cfg: dict, validation_cfg: dict, validation_folder: Path | ||
): | ||
|
||
for key, value in label_cfg.items(): | ||
assert "type" in value | ||
|
||
# rationale: files are on their own and other types are in inputs.json | ||
if not "data:" in value["type"]: | ||
# check that keys are available | ||
assert key in validation_cfg | ||
else: | ||
# it's a file and it should be in the folder as well using key as the filename | ||
filename_to_look_for = key | ||
if "fileToKeyMap" in value: | ||
# ...or there is a mapping | ||
assert len(value["fileToKeyMap"]) > 0 | ||
for filename, mapped_value in value["fileToKeyMap"].items(): | ||
assert mapped_value == key | ||
filename_to_look_for = filename | ||
assert (validation_folder / filename_to_look_for).exists() | ||
else: | ||
assert (validation_folder / filename_to_look_for).exists() | ||
|
||
if validation_cfg: | ||
for key, value in validation_cfg.items(): | ||
# check the key is defined in the labels | ||
assert key in label_cfg | ||
label2types = { | ||
"number": (float, int), | ||
"integer": int, | ||
"boolean": bool, | ||
"string": str, | ||
} | ||
if not "data:" in label_cfg[key]["type"]: | ||
# check the type is correct | ||
assert isinstance(value, label2types[label_cfg[key]["type"]]) |