def get_logging_level_setting(self):
        loggingLevel = Config.getGeneralValue("LogLevel",
                                              "INFORMATION").toUpperCase()

        if loggingLevel == "VERBOSE":
            # Includes this and all of those below
            return MessageType.VERBOSE
        elif loggingLevel == "INFORMATION":
            # Includes this and all of those below
            return MessageType.INFORMATION
        elif loggingLevel == "GENERIC":
            # Includes this and all of those below
            return MessageType.GENERIC
        elif loggingLevel == "SUCCESS":
            # Includes this and all of those below
            return MessageType.SUCCESS
        elif loggingLevel == "WARNING":
            # Includes this and all of those below
            return MessageType.WARNING
        elif loggingLevel == "ERROR":
            # Includes errors only
            return MessageType.ERROR
        elif loggingLevel == "SUSPENDED":
            # All logging is suspended
            return MessageType.SUSPENDED
        else:
            raise ValueError(
                StringProcessor.safeFormatter(
                    "Logging level value '{0}' is not a valid option",
                    Config.getGeneralValue("LogLevel")))
    def addGeneralTestSettingValuesOverrideValuesTest(self):
        newValueMap = {}
        newValueMap.put("BrowserOverride", "CHROME")
        newValueMap.put("TimeoutOverride", "13333333")

        Config.addGeneralTestSettingValues(newValueMap, True)
        self.assertEquals(Config.getGeneralValue("BrowserOverride"), "CHROME")
        self.assertEquals(Config.getGeneralValue("TimeoutOverride"),
                          "13333333")
    def addGeneralTestSettingValuesDontOverrideValuesTest(self):
        newValueMap = {}
        newValueMap.put("DontBrowserOverride", "CHROME")
        newValueMap.put("DontTimeoutOverride", "13333333")

        newValueMapTwo = {}
        newValueMapTwo.put("DontBrowserOverride", "IE")
        newValueMapTwo.put("DontTimeoutOverride", "5555")

        # add values to the override config since the values don't exist in the override config
        Config.addGeneralTestSettingValues(newValueMap, False)
        self.assertEquals(Config.getGeneralValue("DontBrowserOverride"),
                          "CHROME")
        self.assertEquals(Config.getGeneralValue("DontTimeoutOverride"),
                          "13333333")

        # don't add the values to the override config since the values do exist in the override config
        Config.addGeneralTestSettingValues(newValueMapTwo, False)
        self.assertEquals(Config.getGeneralValue("DontBrowserOverride"),
                          "CHROME")
        self.assertEquals(Config.getGeneralValue("DontTimeoutOverride"),
                          "13333333")

        # do add the values because of the override flag
        Config.addGeneralTestSettingValues(newValueMapTwo, True)
        self.assertEquals(Config.getGeneralValue("DontBrowserOverride"), "IE")
        self.assertEquals(Config.getGeneralValue("DontTimeoutOverride"),
                          "5555")
    def get_logging_enabled_setting(self):
        enabledSetting = Config.getGeneralValue("Log", "NO").toUpperCase()

        if enabledSetting == "YES":
            return LoggingEnabled.YES
        elif enabledSetting == "ONFAIL":
            return LoggingEnabled.ONFAIL
        elif enabledSetting == "NO":
            return LoggingEnabled.NO
        else:
            raise ValueError(
                StringProcessor.safeFormatter(
                    "Log value %s is not a valid option",
                    Config.get_general_value("Log", "NO")))
    def get_logger(self, fileName):
        # Disable logging means we just send any logged messages to the console
        if (get_logging_enabled_setting() == LoggingEnabled.NO):
            return ConsoleLogger()

        logDirectory = get_log_directory()
        loggingLevel = get_logging_level_setting()
        logType = Config.getGeneralValue("LogType", "CONSOLE").toUpperCase()

        if logType == "CONSOLE":
            return ConsoleLogger(loggingLevel)
        elif logType == "TXT":
            return FileLogger(False, logDirectory, fileName, loggingLevel)
        else:
            raise ValueError(
                StringProcessor.safeFormatter(
                    "Log type %s is not a valid option",
                    Config.get_general_value("LogType", "CONSOLE")))
 def getGeneralValueTest(self):
     self.assertEquals(Config.getGeneralValue("TestKey"), "testValue")
     self.assertEquals(
         Config.getGeneralValue("nonExistentKey", "defaultValue"),
         "defaultValue")