Beispiel #1
0
 def tearDown(self):
     # call _reset method deleting clearing Translator for unit testing,
     # otherwise the second, third, .. tests will use the instance created
     # in the first test instead of being properly initialized
     temp = util.VariableTranslator(unittest=True)
     temp._reset()
     temp = util.PathManager(unittest=True)
     temp._reset()
Beispiel #2
0
 def setUp(self, mock_read_json):
     # set up translation dictionary without calls to filesystem
     _ = util.VariableTranslator(unittest=True)
     _ = util.PathManager(unittest=True)
 def setUp(self, mock_read_yaml):
     # set up translation dictionary without calls to filesystem
     temp = util.VariableTranslator(unittest_flag = True)
     temp = util.PathManager(unittest_flag = True)
Beispiel #4
0
 def test_variabletranslator_no_key(self, mock_read_yaml):
     temp = util.VariableTranslator(unittest_flag = True)
     self.assertRaises(AssertionError, temp.toCF, 'B', 'PRECT')
     self.assertRaises(KeyError, temp.toCF, 'not_CF', 'nonexistent_var')
     self.assertRaises(AssertionError, temp.fromCF, 'B', 'PRECT')
     self.assertRaises(KeyError, temp.fromCF, 'not_CF', 'nonexistent_var')
Beispiel #5
0
 def test_variabletranslator_cf(self, mock_read_yaml):
     temp = util.VariableTranslator(unittest_flag = True)
     self.assertEqual(temp.toCF('CF', 'pr_var'), 'pr_var')
     self.assertEqual(temp.fromCF('CF', 'pr_var'), 'pr_var')
Beispiel #6
0
 def test_read_model_varnames_multiple(self, mock_read_yaml):
     # create multiple entries when multiple models specified
     temp = util.VariableTranslator(unittest_flag = True)
     self.assertEqual(temp.fromCF('A','B'), 'D')
     self.assertEqual(temp.fromCF('C','B'), 'D')
     temp._reset()
Beispiel #7
0
 def test_read_model_varnames(self, mock_read_yaml):
     # normal operation - convert string to list
     temp = util.VariableTranslator(unittest_flag = True)
     self.assertEqual(temp.fromCF('A','B'), 'D')
     temp._reset()