MCPcopy
hub / github.com/pydata/xarray / test_batchdap4_downloads

Function test_batchdap4_downloads

xarray/tests/test_backends.py:6692–6726  ·  view source on GitHub ↗

Test that in dap4, all dimensions are downloaded at once

(tmpdir, protocol)

Source from the content-addressed store, hash-verified

6690@network
6691@pytest.mark.parametrize("protocol", ["dap2", "dap4"])
6692def test_batchdap4_downloads(tmpdir, protocol) -> None:
6693 """Test that in dap4, all dimensions are downloaded at once"""
6694 import pydap
6695 from pydap.net import create_session
6696
6697 _version_ = Version(pydap.__version__)
6698 # Create a session with pre-set params in pydap backend, to cache urls
6699 cache_name = tmpdir / "debug"
6700 session = create_session(use_cache=True, cache_kwargs={"cache_name": cache_name})
6701 session.cache.clear()
6702 url = "https://test.opendap.org/opendap/hyrax/data/nc/coads_climatology.nc"
6703
6704 ds = open_dataset(
6705 url.replace("https", protocol),
6706 session=session,
6707 engine="pydap",
6708 decode_times=False,
6709 )
6710
6711 if protocol == "dap4":
6712 if _version_ > Version("3.5.5"):
6713 # total downloads are:
6714 # 1 dmr + 1 dap (all dimensions at once)
6715 assert len(session.cache.urls()) == 2
6716 # now load the rest of the variables
6717 ds.load()
6718 # each non-dimension array is downloaded with an individual https requests
6719 assert len(session.cache.urls()) == 2 + 4
6720 else:
6721 assert len(session.cache.urls()) == 4
6722 ds.load()
6723 assert len(session.cache.urls()) == 4 + 4
6724 elif protocol == "dap2":
6725 # das + dds + 3 dods urls for dimensions alone
6726 assert len(session.cache.urls()) == 5
6727
6728
6729class TestEncodingInvalid:

Callers

nothing calls this directly

Calls 3

open_datasetFunction · 0.90
replaceMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…