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

Let the test battery honor DATALAD_TESTS_NONETWORK #504

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions datalad_next/archive_operations/tests/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pytest

from datalad_next.iter_collections.utils import FileSystemItemType
from datalad_next.tests.marker import skipif_no_network

from ..tarfile import TarArchiveOperations

Expand Down Expand Up @@ -37,6 +38,7 @@ def structured_sample_tar_xz(
)


@skipif_no_network
def test_tararchive_basics(structured_sample_tar_xz: TestArchive):
spec = structured_sample_tar_xz
# this is intentionally a hard-coded POSIX relpath
Expand All @@ -48,6 +50,7 @@ def test_tararchive_basics(structured_sample_tar_xz: TestArchive):
assert member.read() == spec.content


@skipif_no_network
def test_tararchive_contain(structured_sample_tar_xz: TestArchive):
# this is intentionally a hard-coded POSIX relpath
member_name = 'test-archive/onetwothree.txt'
Expand All @@ -59,6 +62,7 @@ def test_tararchive_contain(structured_sample_tar_xz: TestArchive):
assert 'bogus' not in archive_ops


@skipif_no_network
def test_tararchive_iterator(structured_sample_tar_xz: TestArchive):
spec = structured_sample_tar_xz
with TarArchiveOperations(spec.path) as archive_ops:
Expand All @@ -68,6 +72,7 @@ def test_tararchive_iterator(structured_sample_tar_xz: TestArchive):
assert item.name in archive_ops


@skipif_no_network
def test_open(structured_sample_tar_xz: TestArchive):
spec = structured_sample_tar_xz
file_pointer = set()
Expand Down
3 changes: 3 additions & 0 deletions datalad_next/commands/tests/test_ls_file_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datalad.api import ls_file_collection

from datalad_next.constraints.exceptions import CommandParametrizationError
from datalad_next.tests.marker import skipif_no_network

from ..ls_file_collection import LsFileCollectionParamValidator

Expand All @@ -30,6 +31,7 @@ def test_ls_file_collection_insufficient_args():
ls_file_collection('bogus', 'http://example.com')


@skipif_no_network
def test_ls_file_collection_tarfile(sample_tar_xz):
kwa = dict(result_renderer='disabled')
# smoke test first
Expand Down Expand Up @@ -84,6 +86,7 @@ def test_ls_file_collection_validator():
val.get_collection_iter(type='bogus', collection='any', hash=None)


@skipif_no_network
def test_replace_add_archive_content(sample_tar_xz, existing_dataset):
kwa = dict(result_renderer='disabled')

Expand Down
3 changes: 3 additions & 0 deletions datalad_next/iter_collections/tests/test_itertar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from datalad.api import download

from datalad_next.tests.marker import skipif_no_network

from ..tarfile import (
TarfileItem,
FileSystemItemType,
Expand Down Expand Up @@ -42,6 +44,7 @@ def sample_tar_xz(tmp_path_factory):
tfpath.unlink()


@skipif_no_network
def test_iter_tar(sample_tar_xz):
target_hash = {'SHA1': 'a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0',
'md5': 'ba1f2511fc30423bdbb183fe33f3dd0f'}
Expand Down
3 changes: 3 additions & 0 deletions datalad_next/patches/tests/test_annex_progress_logging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from datalad_next.tests.marker import skipif_no_network


@skipif_no_network
def test_uncurl_progress_reporting_to_annex(existing_dataset, monkeypatch):
"""Set up a repo that is used to download a key,
check that we see progress reports
Expand Down
4 changes: 4 additions & 0 deletions datalad_next/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@
raises ``SkipTest`` whenever any of these undesired conditions is
detected. Otherwise it just relays ``httpbin_service``.
"""
if os.environ.get('DATALAD_TESTS_NONETWORK'):
raise SkipTest(

Check warning on line 372 in datalad_next/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

datalad_next/tests/fixtures.py#L372

Added line #L372 was not covered by tests
'Not running httpbin-based test: NONETWORK flag set'
)
if 'APPVEYOR' in os.environ and 'DEPLOY_HTTPBIN_IMAGE' not in os.environ:
raise SkipTest(
"Not running httpbin-based test on appveyor without "
Expand Down
7 changes: 7 additions & 0 deletions datalad_next/tests/marker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
import pytest

skipif_no_network = pytest.mark.skipif(
'DATALAD_TESTS_NONETWORK' in os.environ,
reason='DATALAD_TESTS_NONETWORK is set'
)
4 changes: 4 additions & 0 deletions datalad_next/url_operations/tests/test_http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import gzip
import pytest

from datalad_next.tests.marker import skipif_no_network

from ..any import AnyUrlOperations
from ..http import (
HttpUrlOperations,
Expand Down Expand Up @@ -59,6 +61,7 @@ def test_custom_http_headers_via_config(datalad_cfg):
assert huo._headers['X-Funky'] == 'Stuff'


@skipif_no_network
def test_transparent_decompression(tmp_path):
# this file is offered with transparent compression/decompression
# by the github webserver
Expand All @@ -73,6 +76,7 @@ def test_transparent_decompression(tmp_path):
'[build-system]\nrequires = ["setuptools >= 43.0.0", "wheel"]\n'


@skipif_no_network
def test_compressed_file_stay_compressed(tmp_path):
# this file is offered with transparent compression/decompression
# by the github webserver, but is also actually gzip'ed
Expand Down
Loading