Skip to content

Commit a0aed88

Browse files
author
Andrei Neagu
committed
fixed failing tests
1 parent 1732837 commit a0aed88

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

docker-compose-meta.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434
under OUTPUT_FOLDER/output_4 as output_4.zip", "type": "data:*/*", "fileToKeyMap":
3535
{"output_4.zip": "output_4"}}}}'
3636
io.simcore.type: '{"type": "computational"}'
37-
io.simcore.version: '{"version": "1.4.0"}'
37+
io.simcore.version: '{"version": "1.4.1"}'
3838
org.label-schema.build-date: ${BUILD_DATE}
3939
org.label-schema.schema-version: '1.0'
4040
org.label-schema.vcs-ref: ${VCS_REF}

service.cli/run

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#!/bin/sh
23
#---------------------------------------------------------------
34
# AUTO-GENERATED CODE, do not modify this will be overwritten!!!

tests/integration/test_docker_image.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# HELPERS
1919
def _download_url(url: str, file: Path):
2020
# 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:
21+
with urllib.request.urlopen(url) as response, file.open("wb") as out_file:
2222
shutil.copyfileobj(response, out_file)
2323
assert file.exists()
2424

@@ -36,6 +36,20 @@ def _convert_to_simcore_labels(image_labels: Dict) -> Dict:
3636
assert len(io_simcore_labels) > 0
3737
return io_simcore_labels
3838

39+
40+
def _is_url(value: str) -> bool:
41+
"""Check if the value is a URL."""
42+
return isinstance(value, str) and (
43+
value.startswith("http://") or value.startswith("https://")
44+
)
45+
46+
47+
def _fetch_url_content(url: str) -> str:
48+
"""Fetch content from a URL."""
49+
with urllib.request.urlopen(url) as response:
50+
return response.read().decode("utf-8").strip()
51+
52+
3953
# FIXTURES
4054
@pytest.fixture
4155
def osparc_service_labels_jsonschema(tmp_path) -> Dict:
@@ -47,34 +61,43 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict:
4761
return json_schema
4862

4963

50-
@pytest.fixture(scope='session')
64+
@pytest.fixture(scope="session")
5165
def metadata_labels(metadata_file: Path) -> Dict:
5266
with metadata_file.open() as fp:
5367
metadata = yaml.safe_load(fp)
5468
return metadata
5569

70+
5671
# TESTS
5772

5873

59-
def test_docker_io_simcore_labels_against_files(docker_image: docker.models.images.Image, metadata_labels: Dict):
74+
def test_docker_io_simcore_labels_against_files(
75+
docker_image: docker.models.images.Image, metadata_labels: Dict
76+
):
6077
image_labels = docker_image.labels
6178
io_simcore_labels = _convert_to_simcore_labels(image_labels)
6279
# check files are identical
6380
for key, value in io_simcore_labels.items():
6481
assert key in metadata_labels
65-
assert value == metadata_labels[key]
82+
if key == "description":
83+
assert _is_url(metadata_labels[key])
84+
assert value == _fetch_url_content(metadata_labels[key])
85+
else:
86+
assert value == metadata_labels[key]
6687

6788

68-
def test_validate_docker_io_simcore_labels(docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict):
89+
def test_validate_docker_io_simcore_labels(
90+
docker_image: docker.models.images.Image, osparc_service_labels_jsonschema: Dict
91+
):
6992
image_labels = docker_image.labels
7093
# get io labels
7194
io_simcore_labels = _convert_to_simcore_labels(image_labels)
7295
# validate schema
7396
try:
74-
jsonschema.validate(io_simcore_labels,
75-
osparc_service_labels_jsonschema)
97+
jsonschema.validate(io_simcore_labels, osparc_service_labels_jsonschema)
7698
except jsonschema.SchemaError:
77-
pytest.fail("Schema {} contains errors".format(
78-
osparc_service_labels_jsonschema))
99+
pytest.fail(
100+
"Schema {} contains errors".format(osparc_service_labels_jsonschema)
101+
)
79102
except jsonschema.ValidationError:
80103
pytest.fail("Failed to validate docker image io labels against schema")

0 commit comments

Comments
 (0)