def test_FileLoggerAppendLogFolder(self):
     append_file_directory_path = LoggingConfig.get_log_directory(
     ) + "/" + "Append File Directory"
     html_logger = HtmlFileLogger(append_file_directory_path, True)
     self.assertEquals(append_file_directory_path,
                       html_logger.get_directory(),
                       "Expected Directory 'Append File Directory'.")
     self.assertEquals("FileLog.html", html_logger.get_file_name(),
                       "Expected correct File Name.")
     self.assertEquals(MessageType.INFORMATION.name,
                       html_logger.get_message_type(),
                       "Expected Information Message Type.")
 def test_FileLoggerLogFolderMessagingLevel(self):
     log_folder_messaging_level_directory_path = LoggingConfig.get_log_directory() + "/" \
                                                 + "Log Folder Messaging Level Directory"
     html_logger = HtmlFileLogger(log_folder_messaging_level_directory_path,
                                  False, MessageType.WARNING)
     self.assertEquals(
         log_folder_messaging_level_directory_path,
         html_logger.get_directory(),
         "Expected Directory 'Log Folder Messaging Level Directory'.")
     self.assertEquals("FileLog.html", html_logger.get_file_name(),
                       "Expected correct File Name.")
     self.assertEquals(MessageType.WARNING.name,
                       html_logger.get_message_type(),
                       "Expected Warning Message Type.")
 def test_FileLoggerLogFolderFileName(self):
     log_folder_file_name_directory = LoggingConfig.get_log_directory(
     ) + "/" + "Log Folder File Name Directory"
     html_logger = HtmlFileLogger(log_folder_file_name_directory,
                                  "LogFolderFileName.html")
     self.assertEquals(
         log_folder_file_name_directory, html_logger.get_directory(),
         "Expected Directory 'Log Folder File Name Directory'.")
     self.assertEquals("LogFolderFileName.html",
                       html_logger.get_file_name(),
                       "Expected correct File Name.")
     self.assertEquals(MessageType.INFORMATION.name,
                       html_logger.get_message_type(),
                       "Expected Information Message Type.")
    def test_FileLoggerMessageTypeOnly(self):
        html_logger = HtmlFileLogger("", False, MessageType.WARNING)
        self.assertEquals(
            html_logger.DEFAULT_LOG_FOLDER, html_logger.get_directory(),
            StringProcessor.safe_formatter("Expected Directory '{}'.",
                                           html_logger.DEFAULT_LOG_FOLDER))
        self.assertEquals("FileLog.html", html_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING, html_logger.get_message_type(),
                          "Expected Warning Message Type.")

        file_path = html_logger.get_file_path(
        ) + "\\" + html_logger.get_file_name()
        self.assertTrue(path.exists(file_path))
    def test_FileLoggerAppendOnly(self):
        html_logger = HtmlFileLogger("", True)
        self.assertEquals(
            html_logger.DEFAULT_LOG_FOLDER, html_logger.get_directory(),
            StringProcessor.safe_formatter("Expected Directory '{}'.",
                                           html_logger.DEFAULT_LOG_FOLDER))
        self.assertEquals("FileLog.html", html_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.INFORMATION.name,
                          html_logger.get_message_type(),
                          "Expected Information Message Type.")

        file_path = html_logger.get_file_path(
        ) + "\\" + html_logger.get_file_name()
        self.assertFalse(path.exists(file_path))
    def test_FileLoggerAppendLogFolderMessagingLevel(self):
        append_log_folder_file_name_directory = LoggingConfig.get_log_directory() + "\\" \
                                                + "AppendLogFolderFileNameDirectory "
        html_logger = HtmlFileLogger(append_log_folder_file_name_directory,
                                     True, MessageType.WARNING)
        self.assertEquals(
            append_log_folder_file_name_directory, html_logger.get_directory(),
            "Expected Directory AppendLogFolderFileNameDirectory")
        self.assertEquals("FileLog.html", html_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING.name,
                          html_logger.get_message_type(),
                          "Expected Warning Message Type.")

        file_path = html_logger.get_file_path(
        ) + "\\" + html_logger.get_file_name()
        self.assertFalse(path.exists(file_path))
    def test_FileLoggerLogFolderFileNameMessagingLevel(self):
        log_folder_file_name_messaging_level_directory_path = LoggingConfig.get_log_directory() \
                                                              + "/" + "LogFolderFileNameMessagingLevelDirectory"
        html_logger = HtmlFileLogger(
            log_folder_file_name_messaging_level_directory_path,
            "LogFolderFileNameMessagingLevel.html", MessageType.WARNING)
        self.assertEquals(
            log_folder_file_name_messaging_level_directory_path,
            html_logger.get_directory(),
            "Expected Directory 'LogFolderFileNameMessagingLevelDirectory'")
        self.assertEquals("LogFolderFileNameMessagingLevel.html",
                          html_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING, html_logger.get_message_type(),
                          "Expected Warning Message Type.")

        file_path = html_logger.get_file_path(
        ) + "\\" + html_logger.get_file_name()
        self.assertTrue(path.exists(file_path))
    def test_HtmlFileLoggerConstructorCreateDirectory(self):
        html_logger = HtmlFileLogger(True,
                                     LoggingConfig().get_log_directory(),
                                     "HtmlFileLoggerCreateDirectory",
                                     MessageType.GENERIC)
        html_logger.log_message(
            MessageType.WARNING,
            "Test to ensure that the file in the created directory can be written to."
        )
        file = html_logger.get_file_path()
        self.assertTrue(
            self.readTextFile(
                self.Test_Message in html_logger.get_file_path()))
        file.delete()
        self.assertTrue(path.exists(html_logger.get_file_path()))
        file = html_logger.get_directory()

        try:
            os.remove(file)
        except IOError as e:
            e.printStackTrace()