Skip to content

Commit 948168f

Browse files
committed
[JTH] add test for ECMWF downloader
1 parent f7ee984 commit 948168f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import tempfile
2+
import unittest
3+
4+
import xarray as xr
5+
6+
from bluemath_tk.downloaders.ecmwf.ecmwf_downloader import ECMWFDownloader
7+
8+
9+
class TestECMWFDownloader(unittest.TestCase):
10+
def setUp(self):
11+
self.temp_dir = tempfile.mkdtemp()
12+
self.downloader = ECMWFDownloader(
13+
product="OpenData",
14+
base_path_to_download="OpenDataJavixu", # self.temp_dir,
15+
check=False, # Just check paths to download, do not actually download
16+
)
17+
18+
def test_list_datasets(self):
19+
datasets = self.downloader.list_datasets()
20+
self.assertIsInstance(datasets, list)
21+
self.assertTrue(len(datasets) > 0)
22+
print(f"Available datasets: {datasets}")
23+
24+
def test_download_data(self):
25+
dataset = self.downloader.download_data(
26+
load_data=True,
27+
param=["msl"],
28+
step=[0, 240],
29+
type="fc",
30+
force=False,
31+
)
32+
self.assertIsInstance(dataset, xr.Dataset)
33+
print(dataset)
34+
35+
36+
if __name__ == "__main__":
37+
unittest.main()

0 commit comments

Comments
 (0)