Skip to content

Commit ac6dd93

Browse files
committed
update testing to show number of download urls
1 parent 6efae9d commit ac6dd93

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
@@ -6452,7 +6452,8 @@ def test_session(self) -> None:
64526452
@requires_pydap
64536453
@network
64546454
@pytest.mark.parametrize("protocol", ["dap2", "dap4"])
6455-
def test_batchdap4_downloads(protocol) -> None:
6455+
@pytest.mark.parametrize("batch", [False, True])
6456+
def test_batchdap4_downloads(protocol, batch) -> None:
64566457
"""Test that in dap4, all dimensions are downloaded at once"""
64576458
import pydap
64586459
from requests_cache import CachedSession
@@ -6462,20 +6463,36 @@ def test_batchdap4_downloads(protocol) -> None:
64626463
session.cache.clear()
64636464
url = "https://test.opendap.org/opendap/hyrax/data/nc/coads_climatology.nc"
64646465

6465-
open_dataset(
6466-
url.replace("https", protocol),
6467-
engine="pydap",
6468-
session=session,
6469-
decode_times=False,
6470-
)
6466+
args = {
6467+
"filename_or_obj": url.replace("https", protocol),
6468+
"engine": "pydap",
6469+
"session": session,
6470+
"decode_times": False,
6471+
}
6472+
64716473
if protocol == "dap4":
6474+
ds = open_dataset(**args, batch=batch)
64726475
if _version_ > Version("3.5.5"):
6473-
# should download 2 urls only (1 dmr and 1 dap)
6476+
# total downloads are:
6477+
# 1 dmr + 1 dap (dimensions)
64746478
assert len(session.cache.urls()) == 2
6479+
# now load the rest of the variables
6480+
ds.load()
6481+
if batch:
6482+
# all non-dimensions are downloaded in a single https requests
6483+
assert len(session.cache.urls()) == 2 + 1
6484+
if not batch:
6485+
# each non-dimension array is downloaded with an individual
6486+
# https requests
6487+
assert len(session.cache.urls()) == 2 + 4
64756488
else:
64766489
assert len(session.cache.urls()) == 4
6477-
# das + dds + 3 dods urls
6490+
ds.load()
6491+
assert len(session.cache.urls()) == 4 + 4
64786492
elif protocol == "dap2":
6493+
ds = open_dataset(**args)
6494+
# das + dds + 3 dods urls
6495+
64796496
assert len(session.cache.urls()) == 5
64806497

64816498

0 commit comments

Comments
 (0)