Skip to content

Commit

Permalink
Merge pull request #265 from asmacdo/lint-metalad-container
Browse files Browse the repository at this point in the history
Fix lint errors other than line length
  • Loading branch information
asmacdo authored Mar 22, 2024
2 parents d5f01ae + 821a298 commit 8ed8cca
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions datalad_container/extractors/tests/test_metalad_container.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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."""
Expand All @@ -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',
Expand All @@ -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()

0 comments on commit 8ed8cca

Please sign in to comment.