Skip to content

Commit

Permalink
fix: use tmp directory for tsad dataset tests and skip internet-downl…
Browse files Browse the repository at this point in the history
…oads in PR testing (#2232)
  • Loading branch information
Sebastian Schmidl authored Oct 20, 2024
1 parent 7980298 commit d49f644
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
21 changes: 21 additions & 0 deletions aeon/datasets/tests/test_tsad_data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
load_from_timeeval_csv_file,
load_kdd_tsad_135,
)
from aeon.testing.testing_config import PR_TESTING


@pytest.mark.skipif(
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_load_anomaly_detection_wrong_name(mocker):
"""Test load non-existent anomaly detection datasets."""
with pytest.raises(
Expand All @@ -32,6 +37,10 @@ def test_load_anomaly_detection_wrong_name(mocker):
load_anomaly_detection(("FOO", "BAR"))


@pytest.mark.skipif(
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_load_anomaly_detection_no_train_split(mocker):
"""Test load train split of anomaly detection dataset without training split."""
name = ("Dodgers", "101-freeway-traffic")
Expand All @@ -44,6 +53,10 @@ def test_load_anomaly_detection_no_train_split(mocker):
load_anomaly_detection(name, extract_path=tmp, split="train")


@pytest.mark.skipif(
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_load_anomaly_detection_from_archive(mocker):
"""Test load anomaly detection dataset from archive."""
name = ("Genesis", "genesis-anomalies")
Expand All @@ -63,6 +76,10 @@ def test_load_anomaly_detection_from_archive(mocker):
np.testing.assert_almost_equal(meta["contamination"], 0.0031, decimal=4)


@pytest.mark.skipif(
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_load_anomaly_detection_unavailable(mocker):
"""Test load anomaly detection dataset that is not available."""
name = ("IOPS", "05f10d3a-239c-3bef-9bdc-a2feeb0037aa")
Expand All @@ -74,6 +91,10 @@ def test_load_anomaly_detection_unavailable(mocker):
load_anomaly_detection(name)


@pytest.mark.skipif(
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_load_anomaly_detection_custom_file(mocker):
"""Test load anomaly detection dataset from custom file."""
name = ("correlation-anomalies", "rmj-2-short-2-diff-channel")
Expand Down
32 changes: 19 additions & 13 deletions aeon/datasets/tests/test_tsad_datasets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Test functions in tsad_datasets.py."""

import tempfile
from pathlib import Path

import pytest

from aeon.datasets.tsad_datasets import (
Expand All @@ -17,17 +20,20 @@
PR_TESTING,
reason="Only run on overnights because of read from internet.",
)
def test_helper_functions():
def test_helper_functions(mocker):
"""Test helper functions."""
d = tsad_collections()
assert isinstance(d, dict)
d = tsad_datasets()
assert isinstance(d, list)
d = univariate()
assert isinstance(d, list)
d = multivariate()
assert isinstance(d, list)
d = unsupervised()
assert isinstance(d, list)
d = supervised()
assert isinstance(d, list)
with tempfile.TemporaryDirectory() as tmp:
tmp = Path(tmp)
mocker.patch("aeon.datasets.tsad_datasets._DATA_FOLDER", tmp)
d = tsad_collections()
assert isinstance(d, dict)
d = tsad_datasets()
assert isinstance(d, list)
d = univariate()
assert isinstance(d, list)
d = multivariate()
assert isinstance(d, list)
d = unsupervised()
assert isinstance(d, list)
d = supervised()
assert isinstance(d, list)

0 comments on commit d49f644

Please sign in to comment.