Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoranAngevaare committed Jun 14, 2023
1 parent 9d5fc84 commit e555f26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion optim_esm_tools/_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
18 changes: 18 additions & 0 deletions test/test_find_matches.py
Original file line number Diff line number Diff line change
@@ -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,
))

0 comments on commit e555f26

Please sign in to comment.