Skip to content

Commit 6dfebd9

Browse files
committed
Adds unit test verifying engine is passed
This commit adds a simple mocked-based unit test that verifies engine is passed to open_mfdataset in OpenDapSource._open_dataset.
1 parent 9db6cf5 commit 6dfebd9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

intake_xarray/tests/test_intake_xarray.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,22 @@ def test_read_opendap_with_auth(auth):
332332
)
333333

334334

335+
def test_read_opendap_mfdataset_with_engine():
336+
pytest.importorskip("pydap")
337+
from intake_xarray.opendap import OpenDapSource
338+
urls = [
339+
'http://example.com/opendap/fake1.nc',
340+
'http://example.com/opendap/fake2.nc',
341+
]
342+
with patch('xarray.open_mfdataset') as open_mfdataset_mock:
343+
open_mfdataset_mock.return_value = 'dataset'
344+
source = OpenDapSource(urlpath=urls, chunks={}, auth=None, engine='fake-engine')
345+
source._open_dataset()
346+
retval = source._ds
347+
assert open_mfdataset_mock.called_with(urls, chunks={}, engine='fake-engine')
348+
assert retval == 'dataset'
349+
350+
335351
@pytest.mark.parametrize("auth", ["esgf", "urs"])
336352
def test_read_opendap_with_auth_netcdf4(auth):
337353
from intake_xarray.opendap import OpenDapSource

0 commit comments

Comments
 (0)