def setUp(self): temp = util.PathManager(unittest_flag = True) self.config_test = { 'case_list':[{'A':'B'}], 'paths':{'C':'/D'}, 'settings':{'E':'F', 'verbose':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()
def test_pathmgr_pod(self, mock_exists, mock_read_yaml): paths = util.PathManager(unittest_flag = True) pod = Diagnostic('A') pod.MODEL_WK_DIR = 'B' d = paths.podPaths(pod) self.assertEqual(d['POD_CODE_DIR'], 'TEST_CODE_ROOT/diagnostics/A') self.assertEqual(d['POD_OBS_DATA'], 'TEST_OBS_DATA_ROOT/A') self.assertEqual(d['POD_WK_DIR'], 'B/A')
def test_pathmgr_global_asserterror(self): d = { 'OBS_DATA_ROOT':'B', 'MODEL_DATA_ROOT':'C', 'WORKING_DIR':'D', 'OUTPUT_DIR':'E' } self.assertRaises(AssertionError, util.PathManager, d) # initialize successfully so that tearDown doesn't break paths = util.PathManager(unittest_flag = True)
def test_pathmgr_global(self): d = { 'CODE_ROOT':'A', 'OBS_DATA_ROOT':'B', 'MODEL_DATA_ROOT':'C', 'WORKING_DIR':'D', 'OUTPUT_DIR':'E' } paths = util.PathManager(d) self.assertEqual(paths.CODE_ROOT, 'A') self.assertEqual(paths.OUTPUT_DIR, 'E')
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): # set up paths without calls to filesystem temp = util.PathManager(unittest_flag = 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)
def test_pathmgr_pod_nomodel(self, mock_exists, mock_read_yaml): paths = util.PathManager(unittest_flag = True) pod = Diagnostic('A') d = paths.podPaths(pod) self.assertEqual(d['POD_CODE_DIR'], 'TEST_CODE_ROOT/diagnostics/A') self.assertNotIn('POD_WK_DIR', d)
def test_pathmgr_model(self): paths = util.PathManager(unittest_flag = True) case = DataManager(self.default_case) d = paths.modelPaths(case) self.assertEqual(d['MODEL_DATA_DIR'], 'TEST_MODEL_DATA_ROOT/A') self.assertEqual(d['MODEL_WK_DIR'], 'TEST_WORKING_DIR/MDTF_A_1900_2100')
def test_pathmgr_global_testmode(self): paths = util.PathManager(unittest_flag = True) self.assertEqual(paths.CODE_ROOT, 'TEST_CODE_ROOT') self.assertEqual(paths.OUTPUT_DIR, 'TEST_OUTPUT_DIR')