Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors other than line length #265

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()