class TestTableCheckerTask(unittest.TestCase): """ test for table checker """ def setUp(self): """ init a great process manager""" self._p_m = ProcesserManager() self._p_m.init_class("col_checker", "col_checker_time.ColTimeChecker") self._p_m.init_class("col_checker", "col_checker_type.ColTypeChecker") self._p_m.init_class("preprocesser", "preprocess_time.PreprocessTime") self._p_m.init_class("preprocesser", "preprocess_trim.PreprocessTrim") #self._p_m.init_class("join_checker", "") col_check_task = [] col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["0", None, None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["int"], [["1", None, None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["int"], [["2", "preprocess_trim.PreprocessTrim", None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["float"], [["3", "preprocess_trim.PreprocessTrim", None]])) col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["4", "preprocess_time.PreprocessTime", None]])) col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["5", "preprocess_time.PreprocessTime", ["%Y:%M:%d"]]])) line = assemble_parameter("./data/table_checker/file_in", 6, ",", col_check_task) self._checker = TableCheckerTask(line) def tearDown(self): del self._p_m del self._checker def test_get_process_name(self): """ test for get process name """ names = self._checker.get_process_name() real_names = [ ["col_checker", "col_checker_time.ColTimeChecker", ["%Y-%m-%d %H:%M:%S"]], \ ["col_checker", "col_checker_type.ColTypeChecker", ["int"]], \ ["col_checker", "col_checker_type.ColTypeChecker", ["int"]], \ ["col_checker", "col_checker_type.ColTypeChecker", ["float"]], \ ["col_checker", "col_checker_time.ColTimeChecker", ["%Y-%m-%d %H:%M:%S"]], \ ["col_checker", "col_checker_time.ColTimeChecker", ["%Y-%m-%d %H:%M:%S"]], \ ["preprocesser" , "preprocess_trim.PreprocessTrim", None], \ ["preprocesser" , "preprocess_trim.PreprocessTrim", None], \ ["preprocesser" , "preprocess_time.PreprocessTime", None], \ ["preprocesser" , "preprocess_time.PreprocessTime", ["%Y:%M:%d"]], \ ] for name in names: self.assertIn(name, real_names) def test_excute(self): self._checker.excute(self._p_m) status_infos = self._checker._status_infos line_cnt = 10 reals = [8, 9, 9, 9, 9, 10, 10] for index, s in enumerate(status_infos): self.assertEqual(s.check_cnt, line_cnt) self.assertEqual(s.check_fail_cnt, line_cnt - reals[index])
def setUp(self): """ init a great process manager""" self._p_m = ProcesserManager() self._p_m.init_class("col_checker", "col_checker_time.ColTimeChecker") self._p_m.init_class("col_checker", "col_checker_type.ColTypeChecker") self._p_m.init_class("preprocesser", "preprocess_time.PreprocessTime") self._p_m.init_class("preprocesser", "preprocess_trim.PreprocessTrim") #self._p_m.init_class("join_checker", "") col_check_task = [] col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["0", None, None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["int"], [["1", None, None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["int"], [["2", "preprocess_trim.PreprocessTrim", None]])) col_check_task.append(assemble_sub_task("col_checker_type.ColTypeChecker", \ ["float"], [["3", "preprocess_trim.PreprocessTrim", None]])) col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["4", "preprocess_time.PreprocessTime", None]])) col_check_task.append(assemble_sub_task("col_checker_time.ColTimeChecker", \ ["%Y-%m-%d %H:%M:%S"], [["5", "preprocess_time.PreprocessTime", ["%Y:%M:%d"]]])) line = assemble_parameter("./data/table_checker/file_in", 6, ",", col_check_task) self._checker = TableCheckerTask(line)