def test_parse_frepp_stub_substitution(self): d = gfdl.parse_frepp_stub(self.frepp_stub) self.assertNotIn('in_data_dir', d) self.assertEqual(d['OUTPUT_DIR'], '/foo/bar') self.assertEqual(d['CASENAME'], 'baz.r1i1p1f1') self.assertNotIn('yr1', d) self.assertEqual(d['FIRSTYR'], 1977) self.assertEqual(d['make_variab_tar'], True)
def test_parse_mdtf_args_frepp_overwrite_both(self): # overwrite defaults and command-line d = gfdl.parse_frepp_stub(self.frepp_stub) args = {'frepp': True, 'OUTPUT_DIR': '/X', 'E': 'Y'} mdtf = MDTFFramework.__new__(MDTFFramework) config = self.config_test.copy() config = MDTFFramework.parse_mdtf_args([d, args], config) self.assertEqual(config['paths']['OUTPUT_DIR'], '/foo/bar') self.assertEqual(config['settings']['make_variab_tar'], True) self.assertEqual(config['settings']['E'], 'Y')
def test_parse_mdtf_args_frepp_overwrite(self): # overwrite defaults frepp_stub = self.frepp_stub # make a copy to be safe d = gfdl.parse_frepp_stub(frepp_stub) args = {'frepp': True} mdtf = MDTFFramework.__new__(MDTFFramework) config = self.config_test.copy() config = MDTFFramework.parse_mdtf_args([d, args], config) self.assertEqual(config['paths']['OUTPUT_DIR'], '/foo/bar') self.assertEqual(config['settings']['make_variab_tar'], True) self.assertEqual(config['settings']['E'], 'F')
def test_parse_mdtf_args_frepp_caselist(self): # overwrite defaults and command-line d = gfdl.parse_frepp_stub(self.frepp_stub) args = {'frepp': True} mdtf = MDTFFramework.__new__(MDTFFramework) config = self.config_test.copy() config = MDTFFramework.parse_mdtf_args([d, args], config) self.assertEqual(len(config['case_list']), 1) self.assertEqual(config['case_list'][0]['CASENAME'], 'baz.r1i1p1f1') self.assertEqual(config['case_list'][0]['model'], 'CMIP_GFDL') self.assertEqual(config['case_list'][0]['variable_convention'], 'CMIP_GFDL') self.assertEqual(config['case_list'][0]['FIRSTYR'], 1977) self.assertEqual(config['case_list'][0]['LASTYR'], 1981)
def test_parse_frepp_stub_regex(self): frepp_stub = """ set foo1 = bar set foo2 = /complicated/path_name/1-2.3 set foo3 = "./relative path/with spaces.txt" set foo4 = 1 set foo5 = # comment set foo6 = not a #comment """ d = gfdl.parse_frepp_stub(frepp_stub) self.assertEqual(d['foo1'], 'bar') self.assertEqual(d['foo2'], '/complicated/path_name/1-2.3') self.assertEqual(d['foo3'], '"./relative path/with spaces.txt"') self.assertEqual(d['foo4'], '1') self.assertNotIn('foo5', d) self.assertEqual(d['foo6'], 'not a #comment')
def test_parse_frepp_stub_mode(self): frepp_stub = self.frepp_stub # make a copy to be safe d = gfdl.parse_frepp_stub(frepp_stub) self.assertEqual(d['frepp'], True)
def test_parse_frepp_stub_mode(self): d = gfdl.parse_frepp_stub(self.frepp_stub) self.assertEqual(d['frepp'], True)