def test_not_add_logs_that_do_not_comply_with_the_data_types(self): log = LogHelper() log.debug(self.DEBUG_MESSAGE) log.info(self.INFO_MESSAGE) log.warning(self.WARNING_MESSAGE) log.error(self.ERROR_MESSAGE) log.fatal(self.FATAL_MESSAGE) log.add_external_logs([1, 2, 3, 'uno', 'dos']) log.add_external_logs('datos') self.assertTrue(log.logs.__len__() == 5)
def test_add_external_logs(self): log = LogHelper() external_logs = LogHelper() log.debug(self.DEBUG_MESSAGE) log.info(self.INFO_MESSAGE) log.warning(self.WARNING_MESSAGE) log.error(self.ERROR_MESSAGE) log.fatal(self.FATAL_MESSAGE) external_msg_debug = 'Mensaje de debug externo' external_msg_info = 'Mensaje de info externo' external_msg_warning = 'Mensaje de warning externo' external_msg_error = 'Mensaje de error externo' external_msg_fatal = 'Mensaje de fatal externo' external_logs.debug(external_msg_debug) external_logs.info(external_msg_info) external_logs.warning(external_msg_warning) external_logs.error(external_msg_error) external_logs.fatal(external_msg_fatal) log.add_external_logs(external_logs.logs) self.assertTrue(log.logs.__len__() == 10) log_name = 'test_add_external_logs.log' self.assertEqual(log.save_logs(log_name, log_level=LogHelper.DEBUG), True) with open(f'./{log_name}') as file: data = file.read() self.assertTrue(self.DEBUG_MESSAGE in data) self.assertTrue(self.INFO_MESSAGE in data) self.assertTrue(self.WARNING_MESSAGE in data) self.assertTrue(self.ERROR_MESSAGE in data) self.assertTrue(self.FATAL_MESSAGE in data) self.assertTrue(external_msg_debug in data) self.assertTrue(external_msg_info in data) self.assertTrue(external_msg_warning in data) self.assertTrue(external_msg_error in data) self.assertTrue(external_msg_fatal in data)