@@ -6449,6 +6449,53 @@ def test_session(self) -> None:
64496449 )
64506450
64516451
6452+ @requires_pydap
6453+ @network
6454+ @pytest .mark .parametrize ("protocol" , ["dap2" , "dap4" ])
6455+ def test_batchdap4_downloads (protocol ) -> None :
6456+ """Test that in dap4, all dimensions are downloaded at once"""
6457+ import pydap
6458+ from requests_cache import CachedSession
6459+
6460+ _version_ = Version (pydap .__version__ )
6461+ session = CachedSession ()
6462+ session .cache .clear ()
6463+ url = "https://test.opendap.org/opendap/hyrax/data/nc/coads_climatology.nc"
6464+
6465+ open_dataset (
6466+ url .replace ("https" , protocol ),
6467+ engine = "pydap" ,
6468+ session = session ,
6469+ decode_times = False ,
6470+ )
6471+ if protocol == "dap4" :
6472+ if _version_ > Version ("3.5.5" ):
6473+ # should download 2 urls only (1 dmr and 1 dap)
6474+ assert len (session .cache .urls ()) == 2
6475+ else :
6476+ assert len (session .cache .urls ()) == 4
6477+ # das + dds + 3 dods urls
6478+ elif protocol == "dap2" :
6479+ assert len (session .cache .urls ()) == 5
6480+
6481+
6482+ @requires_pydap
6483+ @network
6484+ def test_batch_warnswithdap2 () -> None :
6485+ from requests_cache import CachedSession
6486+
6487+ session = CachedSession ()
6488+ session .cache .clear ()
6489+ url = "dap2://test.opendap.org/opendap/hyrax/data/nc/coads_climatology.nc"
6490+ with pytest .warns (UserWarning ):
6491+ open_dataset (
6492+ url , engine = "pydap" , session = session , batch = True , decode_times = False
6493+ )
6494+
6495+ # no batching is supported here
6496+ assert len (session .cache .urls ()) == 5
6497+
6498+
64526499class TestEncodingInvalid :
64536500 def test_extract_nc4_variable_encoding (self ) -> None :
64546501 var = xr .Variable (("x" ,), [1 , 2 , 3 ], {}, {"foo" : "bar" })
0 commit comments