1818# HELPERS
1919def _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,20 +36,6 @@ 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-
5339# FIXTURES
5440@pytest .fixture
5541def osparc_service_labels_jsonschema (tmp_path ) -> Dict :
@@ -61,43 +47,34 @@ def osparc_service_labels_jsonschema(tmp_path) -> Dict:
6147 return json_schema
6248
6349
64- @pytest .fixture (scope = " session" )
50+ @pytest .fixture (scope = ' session' )
6551def metadata_labels (metadata_file : Path ) -> Dict :
6652 with metadata_file .open () as fp :
6753 metadata = yaml .safe_load (fp )
6854 return metadata
6955
70-
7156# TESTS
7257
7358
74- def test_docker_io_simcore_labels_against_files (
75- docker_image : docker .models .images .Image , metadata_labels : Dict
76- ):
59+ def test_docker_io_simcore_labels_against_files (docker_image : docker .models .images .Image , metadata_labels : Dict ):
7760 image_labels = docker_image .labels
7861 io_simcore_labels = _convert_to_simcore_labels (image_labels )
7962 # check files are identical
8063 for key , value in io_simcore_labels .items ():
8164 assert key in metadata_labels
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 ]
65+ assert value == metadata_labels [key ]
8766
8867
89- def test_validate_docker_io_simcore_labels (
90- docker_image : docker .models .images .Image , osparc_service_labels_jsonschema : Dict
91- ):
68+ def test_validate_docker_io_simcore_labels (docker_image : docker .models .images .Image , osparc_service_labels_jsonschema : Dict ):
9269 image_labels = docker_image .labels
9370 # get io labels
9471 io_simcore_labels = _convert_to_simcore_labels (image_labels )
9572 # validate schema
9673 try :
97- jsonschema .validate (io_simcore_labels , osparc_service_labels_jsonschema )
74+ jsonschema .validate (io_simcore_labels ,
75+ osparc_service_labels_jsonschema )
9876 except jsonschema .SchemaError :
99- pytest .fail (
100- "Schema {} contains errors" .format (osparc_service_labels_jsonschema )
101- )
77+ pytest .fail ("Schema {} contains errors" .format (
78+ osparc_service_labels_jsonschema ))
10279 except jsonschema .ValidationError :
10380 pytest .fail ("Failed to validate docker image io labels against schema" )
0 commit comments