Skip to content

Commit b5e4cc0

Browse files
author
Andrei Neagu
committed
fixing test
1 parent 97d3fbd commit b5e4cc0

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/integration/test_docker_image.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# pylint:disable=redefined-outer-name
44

55
import json
6+
from copy import deepcopy
67
import shutil
78
import urllib.request
89
from pathlib import Path
@@ -18,7 +19,7 @@
1819
# HELPERS
1920
def _download_url(url: str, file: Path):
2021
# Download the file from `url` and save it locally under `file_name`:
21-
with urllib.request.urlopen(url) as response, file.open('wb') as out_file:
22+
with urllib.request.urlopen(url) as response, file.open("wb") as out_file:
2223
shutil.copyfileobj(response, out_file)
2324
assert file.exists()
2425

@@ -36,6 +37,7 @@ def _convert_to_simcore_labels(image_labels: Dict) -> Dict:
3637
assert len(io_simcore_labels) > 0
3738
return io_simcore_labels
3839

40+
3941
# FIXTURES
4042
@pytest.fixture
4143
def osparc_service_labels_jsonschema(tmp_path) -> Dict:
@@ -44,19 +46,23 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict:
4446
_download_url(url, file_name)
4547
with file_name.open() as fp:
4648
json_schema = json.load(fp)
49+
json_schema["properties"]["icon"] = deepcopy(json_schema["properties"]["thumbnail"])
4750
return json_schema
4851

4952

50-
@pytest.fixture(scope='session')
53+
@pytest.fixture(scope="session")
5154
def metadata_labels(metadata_file: Path) -> Dict:
5255
with metadata_file.open() as fp:
5356
metadata = yaml.safe_load(fp)
5457
return metadata
5558

59+
5660
# TESTS
5761

5862

59-
def test_docker_io_simcore_labels_against_files(docker_image: docker.models.images.Image, metadata_labels: Dict):
63+
def test_docker_io_simcore_labels_against_files(
64+
docker_image: docker.models.images.Image, metadata_labels: Dict
65+
):
6066
image_labels = docker_image.labels
6167
io_simcore_labels = _convert_to_simcore_labels(image_labels)
6268
# check files are identical
@@ -65,16 +71,18 @@ def test_docker_io_simcore_labels_against_files(docker_image: docker.models.imag
6571
assert value == metadata_labels[key]
6672

6773

68-
def test_validate_docker_io_simcore_labels(docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict):
74+
def test_validate_docker_io_simcore_labels(
75+
docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict
76+
):
6977
image_labels = docker_image.labels
7078
# get io labels
7179
io_simcore_labels = _convert_to_simcore_labels(image_labels)
7280
# validate schema
7381
try:
74-
jsonschema.validate(io_simcore_labels,
75-
osparc_service_labels_jsonschema)
82+
jsonschema.validate(io_simcore_labels, osparc_service_labels_jsonschema)
7683
except jsonschema.SchemaError:
77-
pytest.fail("Schema {} contains errors".format(
78-
osparc_service_labels_jsonschema))
84+
pytest.fail(
85+
"Schema {} contains errors".format(osparc_service_labels_jsonschema)
86+
)
7987
except jsonschema.ValidationError:
8088
pytest.fail("Failed to validate docker image io labels against schema")

0 commit comments

Comments
 (0)