def FileLoggerAppendLogFolder(self):
        append_file_directory_path = LoggingConfig.getLogDirectory(
        ) + "/" + "Append File Directory"
        logger = HtmlFileLogger(append_file_directory_path, True)

        softAssert = SoftAssert()
        softAssert.assertEquals(append_file_directory_path,
                                logger.getDirectory(),
                                "Expected Directory 'Append File Directory'.")
        softAssert.assertEquals("FileLog.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.INFORMATION,
                                logger.getMessageType(),
                                "Expected Information Message Type.")
        softAssert.assertAll()
    def FileLoggerLogFolderMessagingLevel(self):
        log_folder_messaging_level_directory_path = LoggingConfig.getLogDirectory(
        ) + "/" + "Log Folder Messaging Level Directory"
        logger = HtmlFileLogger(log_folder_messaging_level_directory_path,
                                MessageType.WARNING)

        softAssert = SoftAssert()
        softAssert.assertEquals(
            log_folder_messaging_level_directory_path, logger.getDirectory(),
            "Expected Directory 'Log Folder Messaging Level Directory'.")
        softAssert.assertEquals("FileLog.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.WARNING, logger.getMessageType(),
                                "Expected Warning Message Type.")
        softAssert.assertAll()
    def FileLoggerLogFolderFileName(self):
        log_folder_file_name_directory = LoggingConfig.getLogDirectory(
        ) + "/" + "Log Folder File Name Directory"
        logger = HtmlFileLogger(log_folder_file_name_directory,
                                "LogFolderFileName.html")

        softAssert = SoftAssert()
        softAssert.assertEquals(
            log_folder_file_name_directory, logger.getDirectory(),
            "Expected Directory 'Log Folder File Name Directory'.")
        softAssert.assertEquals("LogFolderFileName.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.INFORMATION,
                                logger.getMessageType(),
                                "Expected Information Message Type.")
        softAssert.assertAll()
    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 HtmlFileLoggerSetFilePath(self):
        logger = HtmlFileLogger(True, "", "HtmlFileLoggerSetFilePath",
                                MessageType.GENERIC)
        logger.setFilePath("test file path")
        filePath = logger.getFilePath()

        file = logger.getFilePath()
        file.delete()
        self.assertEquals(filePath, "test file path",
                          "Expected 'test file path' as file path")
    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 FileLoggerMessagingLevelFileName(self):
        logger = HtmlFileLogger(MessageType.WARNING, "MessagingTypeFile.html")

        softAssert = SoftAssert()
        softAssert.assertEquals(
            System.getProperty("java.io.tmpdir"), logger.getDirectory(),
            StringProcessor.safeFormatter(
                "Expected Directory '%s'.",
                System.getProperty("java.io.tmpdir")))
        softAssert.assertEquals("MessagingTypeFile.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.WARNING, logger.getMessageType(),
                                "Expected Warning Message Type.")

        softAssert.assertAll()

        file = logger.getFilePath()
        file.delete()
    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 FileLoggerAppendLogFolderMessagingLevel(self):
        appendLogFolderFileNameDirectory = LoggingConfig.getLogDirectory(
        ) + "/" + "AppendLogFolderFileNameDirectory"
        logger = HtmlFileLogger(True, appendLogFolderFileNameDirectory,
                                MessageType.WARNING)

        softAssert = SoftAssert()
        softAssert.assertEquals(
            appendLogFolderFileNameDirectory, logger.getDirectory(),
            " Expected Directory AppendLogFolderFileNameDirectory")
        softAssert.assertEquals("FileLog.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.WARNING, logger.getMessageType(),
                                "Expected Warning Message Type.")

        softAssert.assertAll()

        file = logger.getFilePath()
        file.delete()
    def FileLoggerAppendFileName(self):
        logger = HtmlFileLogger(True, "AppendFileName")

        softAssert = SoftAssert()
        softAssert.assertEquals(
            System.getProperty("java.io.tmpdir"), logger.getDirectory(),
            StringProcessor.safeFormatter(
                "Expected Directory '%s'.",
                System.getProperty("java.io.tmpdir")))
        softAssert.assertEquals("AppendFileName.html", logger.getFileName(),
                                "Expected correct File Name.")
        softAssert.assertEquals(MessageType.INFORMATION,
                                logger.getMessageType(),
                                "Expected Information Message Type.")

        softAssert.assertAll()

        file = logger.getFilePath()
        file.delete()
    def FileLoggerLogFolderFileNameMessagingLevel(self):
        logFolderFileNameMessagingLevelDirectoryPath = LoggingConfig.getLogDirectory(
        ) + "/" + "LogFolderFileNameMessagingLevelDirectory"
        logger = HtmlFileLogger(logFolderFileNameMessagingLevelDirectoryPath,
                                "LogFolderFileNameMessagingLevel.html",
                                MessageType.WARNING)

        softAssert = SoftAssert()
        softAssert.assert_equals(
            logFolderFileNameMessagingLevelDirectoryPath,
            logger.getDirectory(),
            "Expected Directory 'LogFolderFileNameMessagingLevelDirectory'")
        softAssert.assert_equals("LogFolderFileNameMessagingLevel.html",
                                 logger.getFileName(),
                                 "Expected correct File Name.")
        softAssert.assert_equals(MessageType.WARNING, logger.getMessageType(),
                                 "Expected Warning Message Type.")

        softAssert.assert_all()

        file = logger.getFilePath()
        file.delete()
 def HtmlFileLoggerEmptyFileNameException(self):
     logger = HtmlFileLogger("")
    def WriteToHtmlFileLogger(self):
        logger = HtmlFileLogger("", "WriteToHtmlFileLogger")
        logger.logMessage(MessageType.WARNING, "Hello, this is a test.")

        file = logger.getFilePath()
        file.delete()