update tests for query string secrets
MODIFY
tests/conftest.py
tests/conftest.py
@@ -160,6 +160,13 @@ def netcdf_http_paths(netcdf_local_paths, request):
return all_urls, items_per_file
+@pytest.fixture(scope="session")
+def netcdf_http_paths_with_secrets(netcdf_http_paths, fake_secrets):
+ all_urls, items_per_file = netcdf_http_paths
+ all_urls = [url + fake_secrets for url in all_urls]
+ return all_urls, items_per_file
+
+
@pytest.fixture()
def tmp_target(tmpdir_factory):
fs = fsspec.get_filesystem_class("file")()
@@ -175,6 +182,11 @@ def tmp_cache(tmpdir_factory):
return cache
+@pytest.fixture(scope="session")
+def fake_secrets():
+ return "?a-pretend-api-token"
+
+
@pytest.fixture()
def tmp_metadata_target(tmpdir_factory):
path = str(tmpdir_factory.mktemp("cache"))

MODIFY
tests/test_storage.py
tests/test_storage.py
@@ -40,25 +40,32 @@ def test_metadata_target(tmp_metadata_target):
@pytest.mark.parametrize(
- "file_paths", [lazy_fixture("netcdf_local_paths"), lazy_fixture("netcdf_http_paths")]
+ "file_paths",
+ [
+ lazy_fixture("netcdf_local_paths"), lazy_fixture("netcdf_http_paths"),
+ lazy_fixture("netcdf_http_paths_with_secrets"),
+ ]
)
@pytest.mark.parametrize("copy_to_local", [False, True])
@pytest.mark.parametrize("use_cache, cache_first", [(False, False), (True, False), (True, True)])
@pytest.mark.parametrize("use_dask", [True, False])
@pytest.mark.parametrize("use_xarray", [True, False])
+@pytest.mark.parametrize("use_query_string_secrets", [True, False])
def test_file_opener(
- file_paths, tmp_cache, copy_to_local, use_cache, cache_first, dask_cluster, use_dask, use_xarray
+ file_paths, tmp_cache, fake_secrets, copy_to_local, use_cache, cache_first, dask_cluster,
+ use_dask, use_xarray, use_query_string_secrets,
):
all_paths, _ = file_paths
path = str(all_paths[0])
cache = tmp_cache if use_cache else None
+ secrets = fake_secrets if use_query_string_secrets and file_paths[0][-1] == "?" else None
def do_actual_test():
if cache_first:
- cache.cache_file(path)
+ cache.cache_file(path, secrets)
assert cache.exists(path)
details = cache.fs.ls(cache.root_path, detail=True)
- cache.cache_file(path)
+ cache.cache_file(path, secrets)
# check that nothing happened
assert cache.fs.ls(cache.root_path, detail=True) == details

update tests for query string secrets