diff --git a/optim_esm_tools/_test_utils.py b/optim_esm_tools/_test_utils.py index 553b083d..2c338307 100644 --- a/optim_esm_tools/_test_utils.py +++ b/optim_esm_tools/_test_utils.py @@ -3,9 +3,11 @@ EXMPLE_DATA_SET = 'CMIP6/ScenarioMIP/CCCma/CanESM5/ssp585/r3i1p2f1/Amon/tas/gn/v20190429/tas_Amon_CanESM5_ssp585_r3i1p2f1_gn_201501-210012.nc' +def get_synda_loc(): + return os.path.join(os.environ.get('ST_HOME'), 'data') def get_example_data_loc(): - return os.path.join(os.environ.get('ST_HOME'), 'data', EXMPLE_DATA_SET) + return os.path.join(get_synda_loc(), EXMPLE_DATA_SET) def synda_test_available(): diff --git a/test/test_find_matches.py b/test/test_find_matches.py new file mode 100644 index 00000000..2c13fb7e --- /dev/null +++ b/test/test_find_matches.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +import unittest +import optim_esm_tools as oet +import os +import matplotlib.pyplot as plt +import subprocess +from optim_esm_tools._test_utils import synda_test_available, get_example_data_loc, get_synda_loc + + +@unittest.skipIf(not synda_test_available(), 'synda data not available') +class TestMatches(unittest.TestCase): + def test_find_matches(self): + head = os.path.join(get_synda_loc(), 'CMIP6') + kw = oet.cmip_files.find_matches.folder_to_dict(get_example_data_loc()) + assert len(oet.cmip_files.find_matches.find_matches( + base=head, + **kw, + )) \ No newline at end of file