def test_is_monotonic_increase_3(self): table = pd.DataFrame({"LITERS": [1, 2, 3, 2]}) with self.assertRaises(Exception) as context: DataChecker(table).check_liters_column() self.assertTrue("liters column is not increased (values: [3, 2])" == context.exception.args[0])
def test_t1(self): table = pd.DataFrame({"LITERS": [0, 1, 2, 3], "DUT_1": [0, 0, 2, 5]}) with self.assertRaises(Exception) as context: DataChecker(table).check_all_dut_values() self.assertTrue("dut_values columns is equal (liters values: [0, 1]))" == context.exception.args[0])
def test_is_monotonic_increase_error_2(self): table = pd.DataFrame({"LITERS": [0, 1, 2, 3], "DUT_1": [0, 2, 2, 1]}) with self.assertRaises(Exception) as context: DataChecker(table).check_dut_values() self.assertTrue( "dut_values column is not increased (dut_values: [2, 1] (liters values: [2, 3]))" == context.exception.args[0])
def test_t1(self): table = pd.DataFrame({ "LITERS": [0, 1, 2, 3], "DUT_1": [0, 0, 2, np.nan] }) with self.assertRaises(Exception) as context: DataChecker(table).check_table() self.assertTrue("table has NA" == context.exception.args[0])
def open_file(self): try: wb = openpyxl.load_workbook(self.path) except Exception: raise Exception(f"open error file {self.path}.") n_sheets = len(wb.sheetnames) for sheet_number in range(n_sheets): tank_name = wb.sheetnames[sheet_number] self.fuel_system_config[tank_name] = {} calibration_table = pd.read_excel(self.path, sheet_name=sheet_number, engine='openpyxl') DataChecker(calibration_table).check_table() self.fuel_system_config[tank_name][ "calibration_table"] = calibration_table
def test_is_monotonic_increase_2(): table = pd.DataFrame({"LITERS": [0, 1, 2, 3], "DUT_1": [0, 1, 3, 3]}) DataChecker(table).check_dut_values()
def test_is_monotonic_increase_0(): table = pd.DataFrame({"LITERS": [0, 1, 2, 3]}) DataChecker(table).check_liters_column()
handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) # Init DbHelper - SQLite DB helper = DbHelper() helper.connect() # Read templates reader = TemplateReader() templates = reader.getTml() # Main loop while True: try: data = trap.recv() except pytrap.FormatChanged as e: fmttype, inputspec = trap.getDataFmt(0) rec = pytrap.UnirecTemplate(inputspec) data = e.data if len(data) <= 1: break rec.setData(data) # Check data... DataChecker(rec, templates, helper) # Close DB connection helper.close() # Free allocated TRAP IFCs trap.finalize()