def WriteToExistingHtmlFileLogger(self): logger = HtmlFileLogger(True, "", "WriteToExistingHtmlFileLogger", MessageType.GENERIC) logger.logMessage(MessageType.WARNING, "This is a test.") logger.logMessage(MessageType.WARNING, "This is a test to write to an existing file.") file = logger.getFilePath() file.delete()
def HtmlFileLoggerAppendFileTest(self): logger = HtmlFileLogger(True, "", "WriteToExistingHtmlFileLogger") logger.logMessage(MessageType.WARNING, "This is a test to write to an existing file.") logger.logMessage(MessageType.WARNING, "This is a test to append to current file.") file = logger.getFilePath() file.delete()
def HtmlFileLoggerCatchThrownException(self): logger = HtmlFileLogger(True, "", "HtmlFileLoggerCatchThrownException", MessageType.GENERIC) logger.setFilePath("<>") logger.logMessage(MessageType.GENERIC, "Test throws error as expected.") file = logger.getFilePath() file.delete()
def HtmlFileLoggerLogMessage(self): logger = HtmlFileLogger(True, "", "HtmlFileLoggerLogMessage") logger.logMessage("Test to ensure LogMessage works as expected.") htmlText = self.readTextFile(logger.getFilePath()) file = logger.getFilePath() file.delete() self.assertTrue( htmlText.contains("Test to ensure LogMessage works as expected."), "Expected Log Message to be contained in log.")
def HtmlFileLoggerConstructorCreateDirectory(self): logger = HtmlFileLogger( True, LoggingConfig.getLogDirectory(), "HtmlFileLoggerCreateDirectoryDelete").toString( ), "HtmlFileLoggerCreateDirectory", MessageType.GENERIC logger.logMessage( MessageType.WARNING, "Test to ensure that the file in the created directory can be written to." ) file = logger.getFilePath() self.assertTrue( self.readTextFile(logger.getFilePath()).contains( "Test to ensure that the file in the created directory can be written to." )) file.delete() file = logger.getDirectory() try: os.rename(file) except OSError as e: e.with_traceback
def WriteToHtmlFileLogger(self): logger = HtmlFileLogger("", "WriteToHtmlFileLogger") logger.logMessage(MessageType.WARNING, "Hello, this is a test.") file = logger.getFilePath() file.delete()