Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 28, 2022
1 parent 69cc240 commit e28123e
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .osparc folder
#


#
# test_validation_data_follows_definition:
#
15 changes: 15 additions & 0 deletions packages/service-integration/tests_service/conftest.py
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
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)
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
)
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)
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"]])

0 comments on commit e28123e

Please sign in to comment.