def test_get_syslog_facility_case_insensitive(monkeypatch): """WALE_SYSLOG_FACILITY is case insensitive""" for low_name in ['local' + str(n) for n in range(8)] + ['user']: monkeypatch.setenv('WALE_SYSLOG_FACILITY', low_name) out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True monkeypatch.setenv('WALE_SYSLOG_FACILITY', low_name.upper()) out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True
def test_get_syslog_facility_case_insensitive(): """WALE_SYSLOG_FACILITY is case insensitive""" for low_name in ['local' + unicode(n) for n in xrange(8)] + ['user']: os.environ['WALE_SYSLOG_FACILITY'] = low_name out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True os.environ['WALE_SYSLOG_FACILITY'] = low_name.upper() out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True
def test_get_syslog_facility_notempty(): """WALE_SYSLOG_FACILITY is set""" os.environ['WALE_SYSLOG_FACILITY'] = 'local0' out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_LOCAL0 os.environ['WALE_SYSLOG_FACILITY'] = 'user' out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_USER
def test_get_syslog_facility_notempty(monkeypatch): """WALE_SYSLOG_FACILITY is set""" monkeypatch.setenv('WALE_SYSLOG_FACILITY', 'local0') out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_LOCAL0 monkeypatch.setenv('WALE_SYSLOG_FACILITY', 'user') out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_USER
def test_malformed_destinations(): """WALE_SYSLOG_FACILITY contains bogus values""" os.environ['WALE_SYSLOG_FACILITY'] = 'wat' out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER os.environ['WALE_SYSLOG_FACILITY'] = 'local0,wat' out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER os.environ['WALE_SYSLOG_FACILITY'] = ',' out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER
def test_get_syslog_facility_empty(): """WALE_SYSLOG_FACILITY is not set""" os.environ.clear() out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_USER
def test_malformed_destinations(monkeypatch): """WALE_SYSLOG_FACILITY contains bogus values""" monkeypatch.setenv('WALE_SYSLOG_FACILITY', 'wat') out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER monkeypatch.setenv('WALE_SYSLOG_FACILITY', 'local0,wat') out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER monkeypatch.setenv('WALE_SYSLOG_FACILITY', ',') out, valid_facility = log_help.get_syslog_facility() assert not valid_facility assert out == handlers.SysLogHandler.LOG_USER
def test_get_syslog_facility_empty(monkeypatch): """WALE_SYSLOG_FACILITY is not set""" assert os.getenv('WALE_SYSLOG_FACILITY') is None out, valid_facility = log_help.get_syslog_facility() assert valid_facility is True assert out == handlers.SysLogHandler.LOG_USER