From 2368442cf180cc01598af85fbff90801ac9bb33a Mon Sep 17 00:00:00 2001 From: ntfrgl Date: Tue, 6 Feb 2024 02:28:38 -0800 Subject: [PATCH] TEST: Fixup c5de131 --- tests/conftest.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 76d4820..9820b18 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,17 +35,23 @@ def reanalysis_data() -> Path: - `tests/test_climate/test_map_plot.py` - `examples/tutorials/ClimateNetworks.ipynb` """ - name = "air.mon.mean.nc" - path = Path("./examples/tutorials/data") / name - if not path.exists(): - service = "https://psl.noaa.gov/repository/entry/get" - query = ( - "entryid=synth%3Ae570c8f9-ec09-4e89-93b4-" - "babd5651e7a9%3AL25jZXAucmVhbmFseXNpcy5kZXJpdm" - "VkL3N1cmZhY2UvYWlyLm1vbi5tZWFuLm5j") - url = f"{service}/{name}?{query}" + service = "https://psl.noaa.gov/repository/entry/get" + data_name = "air.mon.mean.nc" + query = ( + "entryid=synth%3Ae570c8f9-ec09-4e89-93b4-" + "babd5651e7a9%3AL25jZXAucmVhbmFseXNpcy5kZXJpdm" + "VkL3N1cmZhY2UvYWlyLm1vbi5tZWFuLm5j") + url = f"{service}/{data_name}?{query}" + + data_dir = Path("./examples/tutorials/data") + data_file = data_dir / data_name + + if not data_dir.is_dir(): + data_dir.mkdir(parents=True) + if not data_file.exists(): res = requests.get(url, timeout=(20, 20)) res.raise_for_status() - with open(path, 'wb') as f: + with open(data_file, 'wb') as f: f.write(res.content) - return path + + return data_file