Skip to content

Commit

Permalink
add basic tests for file download
Browse files Browse the repository at this point in the history
  • Loading branch information
callumrollo committed Jan 16, 2024
1 parent 1b2cab9 commit 8e1868e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions erddapy/erddapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,4 @@ def download_file(
file_name = Path(f"{self.dataset_id}_{constraints_hash}.{file_type}")
if not file_name.exists():
urlretrieve(url, file_name)
return file_name
13 changes: 13 additions & 0 deletions tests/test_to_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,16 @@ def test_to_iris_griddap(dataset_griddap):
"""Test converting griddap to an iris cube."""
cubes = dataset_griddap.to_iris()
assert isinstance(cubes, iris.cube.CubeList)


@pytest.mark.web
def test_download_file(dataset_tabledap):
"""Test direct download of tabledap dataset"""
fn = dataset_tabledap.download_file("nc")
ds = xr.load_dataset(fn)
assert ds["time"].name == "time"
assert ds["temperature"].name == "temperature"
dataset_tabledap.variables = dataset_tabledap.variables[::-1]
fn_new = dataset_tabledap.download_file("nc")
assert fn_new == fn

0 comments on commit 8e1868e

Please sign in to comment.