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 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 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 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 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 WriteToHtmlFileLogger(self):
        logger = HtmlFileLogger("", "WriteToHtmlFileLogger")
        logger.logMessage(MessageType.WARNING, "Hello, this is a test.")

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