Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart committed May 1, 2024
1 parent 9070557 commit 659abc8
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/datasets/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
concat_samples,
disambiguate_timestamp,
download_and_extract_archive,
download_azure_container,
download_radiant_mlhub_collection,
download_radiant_mlhub_dataset,
extract_archive,
Expand Down Expand Up @@ -90,7 +91,12 @@ def mock_missing_module(monkeypatch: MonkeyPatch) -> None:
import_orig = builtins.__import__

def mocked_import(name: str, *args: Any, **kwargs: Any) -> Any:
if name in ["radiant_mlhub", "rarfile", "zipfile_deflate64"]:
if name in [
"azure.storage.blob",
"radiant_mlhub",
"rarfile",
"zipfile_deflate64",
]:
raise ImportError()
return import_orig(name, *args, **kwargs)

Expand Down Expand Up @@ -180,6 +186,27 @@ def test_download_and_extract_archive(tmp_path: Path, monkeypatch: MonkeyPatch)
)


def test_download_azure_container(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
split = "train"
account_url = "https://radiantearth.blob.core.windows.net"
container_name = "mlhub"
name_starts_with = f"nasa-tropical-storm-challenge/{split}/abs_000"
download_azure_container(
account_url=account_url,
container_name=container_name,
root=str(tmp_path),
name_starts_with=name_starts_with,
)


def test_missing_azure_storage_blob(mock_missing_module: None) -> None:
with pytest.raises(
ImportError,
match="azure-storage-blob is not installed and is required to download this dataset",
):
download_azure_container("", "")


def test_download_radiant_mlhub_dataset(
tmp_path: Path, monkeypatch: MonkeyPatch
) -> None:
Expand Down

0 comments on commit 659abc8

Please sign in to comment.