Skip to content

Commit 3ff1a9a

Browse files
committed
update testing to show number of download urls
1 parent b3b77ab commit 3ff1a9a

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

xarray/tests/test_backends.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5968,7 +5968,8 @@ def test_session(self) -> None:
59685968
@requires_pydap
59695969
@network
59705970
@pytest.mark.parametrize("protocol", ["dap2", "dap4"])
5971-
def test_batchdap4_downloads(protocol) -> None:
5971+
@pytest.mark.parametrize("batch", [False, True])
5972+
def test_batchdap4_downloads(protocol, batch) -> None:
59725973
"""Test that in dap4, all dimensions are downloaded at once"""
59735974
import pydap
59745975
from requests_cache import CachedSession
@@ -5978,20 +5979,36 @@ def test_batchdap4_downloads(protocol) -> None:
59785979
session.cache.clear()
59795980
url = "https://test.opendap.org/opendap/hyrax/data/nc/coads_climatology.nc"
59805981

5981-
open_dataset(
5982-
url.replace("https", protocol),
5983-
engine="pydap",
5984-
session=session,
5985-
decode_times=False,
5986-
)
5982+
args = {
5983+
"filename_or_obj": url.replace("https", protocol),
5984+
"engine": "pydap",
5985+
"session": session,
5986+
"decode_times": False,
5987+
}
5988+
59875989
if protocol == "dap4":
5990+
ds = open_dataset(**args, batch=batch)
59885991
if _version_ > Version("3.5.5"):
5989-
# should download 2 urls only (1 dmr and 1 dap)
5992+
# total downloads are:
5993+
# 1 dmr + 1 dap (dimensions)
59905994
assert len(session.cache.urls()) == 2
5995+
# now load the rest of the variables
5996+
ds.load()
5997+
if batch:
5998+
# all non-dimensions are downloaded in a single https requests
5999+
assert len(session.cache.urls()) == 2 + 1
6000+
if not batch:
6001+
# each non-dimension array is downloaded with an individual
6002+
# https requests
6003+
assert len(session.cache.urls()) == 2 + 4
59916004
else:
59926005
assert len(session.cache.urls()) == 4
5993-
# das + dds + 3 dods urls
6006+
ds.load()
6007+
assert len(session.cache.urls()) == 4 + 4
59946008
elif protocol == "dap2":
6009+
ds = open_dataset(**args)
6010+
# das + dds + 3 dods urls
6011+
59956012
assert len(session.cache.urls()) == 5
59966013

59976014

0 commit comments

Comments
 (0)