def test_FileLoggerNoParameters(self):
     file_logger = FileLogger("")
     self.assertEquals(
         tempfile.TemporaryFile(), file_logger.get_directory(),
         StringProcessor.safe_formatter("Expected Directory '{}'.",
                                        file_logger.DEFAULT_LOG_FOLDER))
     self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                       "Expected correct File Name.")
     self.assertEquals(MessageType.INFORMATION,
                       file_logger.get_message_type(),
                       "Expected Information Message Type.")
     os.remove(file_logger.get_file_path())
     self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerAppendMessagingLevel(self):
        file_logger = FileLogger(True, MessageType.WARNING.value)
        self.assertEquals(
            tempfile.TemporaryFile(), file_logger.get_directory(),
            StringProcessor.safe_formatter("Expected Directory '{}'.",
                                           file_logger.DEFAULT_LOG_FOLDER))
        self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING.value,
                          file_logger.get_message_type(),
                          "Expected Warning Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerAppendLogFolder(self):
        append_file_directory = LoggingConfig().get_log_directory(
        ) + "/" + "Append File Directory"
        file_logger = FileLogger(append_file_directory, True)
        self.assertEquals(append_file_directory, file_logger.get_directory(),
                          "Expected Directory 'Append File Directory'.")
        self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.INFORMATION.name,
                          file_logger.get_message_type(),
                          "Expected Information Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerLogFolderMessagingLevel(self):
        file_logger = FileLogger(self.LOG_FOLDER_MESSAGING_LEVEL_DIRECTORY,
                                 MessageType.WARNING)
        self.assertEquals(
            self.LOG_FOLDER_MESSAGING_LEVEL_DIRECTORY,
            file_logger.get_directory(),
            "Expected Directory 'Log Folder Messaging Level Directory'.")
        self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING.value,
                          file_logger.get_message_type(),
                          "Expected Warning Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerAppendOnly(self):
        file_logger = FileLogger("", True)
        self.assertEquals(
            file_logger.DEFAULT_LOG_FOLDER, file_logger.get_directory(),
            StringProcessor.safe_formatter("Expected Directory '{}'.",
                                           file_logger.DEFAULT_LOG_FOLDER))
        self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.INFORMATION.name,
                          file_logger.get_message_type(),
                          "Expected Information Message Type.")

        # os.remove(file_logger.get_file_path() + file_logger.get_file_name())
        self.assertFalse(
            path.exists(os.path.abspath(file_logger.get_file_path())))
    def test_FileLoggerAppendLogFolderMessagingLevel(self):
        append_log_folder_file_name_directory = LoggingConfig().get_log_directory() + "/" + \
                                                "AppendLogFolderFileNameDirectory "
        file_logger = FileLogger(True, append_log_folder_file_name_directory,
                                 MessageType.WARNING)

        self.assertEquals(
            append_log_folder_file_name_directory, file_logger.get_directory(),
            " Expected Directory AppendLogFolderFileNameDirectory")
        self.assertEquals("FileLog.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING.name,
                          file_logger.get_message_type(),
                          "Expected Warning Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerLogFolderFileName(self):
        log_folder_file_name_directory = LoggingConfig().get_log_directory(
        ) + "/" + "Log Folder File Name Directory"
        file_logger = FileLogger(log_folder_file_name_directory,
                                 "LogFolderFileName.txt")

        self.assertEquals(
            log_folder_file_name_directory, file_logger.get_directory(),
            "Expected Directory 'Log Folder File Name Directory'.")
        self.assertEquals("LogFolderFileName.txt", file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.INFORMATION,
                          file_logger.get_message_type(),
                          "Expected Information Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))
    def test_FileLoggerLogFolderFileNameMessagingLevel(self):
        log_folder_file_name_messaging_level_directory = LoggingConfig().get_log_directory() + "/" + \
                                                         "LogFolderFileNameMessagingLevelDirectory"
        file_logger = FileLogger(
            log_folder_file_name_messaging_level_directory,
            "LogFolderFileNameMessagingLevel.txt", MessageType.WARNING)
        self.assertEquals(
            log_folder_file_name_messaging_level_directory,
            file_logger.get_directory(),
            "Expected Directory 'LogFolderFileNameMessagingLevelDirectory'")
        self.assertEquals("LogFolderFileNameMessagingLevel.txt",
                          file_logger.get_file_name(),
                          "Expected correct File Name.")
        self.assertEquals(MessageType.WARNING.name,
                          file_logger.get_message_type(),
                          "Expected Warning Message Type.")

        os.remove(file_logger.get_file_path())
        self.assertTrue(path.exists(file_logger.get_file_path()))