Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from unittest import TestCase
from mock import Mock
from earthdiagnostics.data_convention import DataConvention
class TestDataConvention(TestCase):
def setUp(self):
self.config = Mock()
self.config.experiment.experiment_name = 'experiment_name'
self.config.data_dir = 'data_dir'
self.config.experiment.expid= 'expid'
self.config.cmor.activity = 'activity'
self.config.experiment.institute = 'institute'
self.config.experiment.model = 'model'
self.config.cmor.append_startdate = False
self.convention = DataConvention('name', self.config)
def test_get_filename(self):
with self.assertRaises(NotImplementedError):
self.convention.get_file_name(None, None, None, None, None, None, None, None, None, None)
def test_get_startdate_path(self):
self.assertEqual(self.convention.get_startdate_path('19900101'),
'data_dir/expid/cmorfiles/activity/institute/model/experiment_name')
def test_experiment_name(self):
self.assertEqual(self.convention.experiment_name('19900101'),
'experiment_name')
def test_experiment_name_append(self):
self.config.cmor.append_startdate = True
self.assertEqual(self.convention.experiment_name('19900101'),
'experiment_nameS19900101')
def test_get_cmor_folder_path(self):
with self.assertRaises(NotImplementedError):
self.convention.get_cmor_folder_path(None, None, None, None, None, None, None)