diff --git a/datalad_container/extractors/tests/test_metalad_container.py b/datalad_container/extractors/tests/test_metalad_container.py index 16c81c5..32f3cd4 100644 --- a/datalad_container/extractors/tests/test_metalad_container.py +++ b/datalad_container/extractors/tests/test_metalad_container.py @@ -1,39 +1,18 @@ -import os.path as op import subprocess -import sys -from pathlib import Path -from shutil import which -from unittest.mock import patch import pytest -from datalad.support.external_versions import ( - UnknownVersion, - external_versions, -) +from datalad.support.external_versions import external_versions + # Early detection before we try to import meta_extract from datalad.tests.utils_pytest import SkipTest if not external_versions["datalad_metalad"]: raise SkipTest("skipping metalad tests") -from datalad.api import ( - Dataset, - clone, - meta_extract, -) -from datalad.cmd import ( - StdOutCapture, - WitlessRunner, -) -from datalad.support.exceptions import CommandError +from datalad.api import meta_extract from datalad.tests.utils_pytest import ( SkipTest, - assert_in, - assert_raises, - eq_, - ok_exists, with_tempfile, - with_tree, ) from datalad_container.utils import get_container_command @@ -53,7 +32,8 @@ def test__container_inspect_nofile(path=None): """Singularity causes CalledProcessError if path DNE.""" with pytest.raises(subprocess.CalledProcessError): - result = MetaladContainerInspect._container_inspect(container_command, path) + MetaladContainerInspect._container_inspect(container_command, path) + def test__container_inspect_valid(singularity_test_image): """Call inspect on a valid singularity container image.""" @@ -64,7 +44,7 @@ def test__container_inspect_valid(singularity_test_image): expected_result = { 'data': { 'attributes': { - 'labels':{ + 'labels': { 'org.label-schema.build-date': 'Sat,_19_May_2018_07:06:48_+0000', 'org.label-schema.build-size': '62MB', 'org.label-schema.schema-version': '1.0', @@ -79,12 +59,13 @@ def test__container_inspect_valid(singularity_test_image): } assert result == expected_result + def test_extract(singularity_test_image): ds = singularity_test_image["ds"] path = singularity_test_image["img_path"] result = meta_extract(dataset=ds, extractorname="container_inspect", path=path) assert len(result) == 1 - assert result[0]["metadata_record"]["extracted_metadata"] + assert result[0]["metadata_record"]["extracted_metadata"] assert result[0]["metadata_record"]["extractor_name"] == 'container_inspect' assert result[0]["metadata_record"]["extractor_version"] == MetaladContainerInspect.get_version()