예제 #1
0
def test_config_loads_debug_and_verbose(caplog):
    caplog.set_level(logging.INFO)
    os.environ['ELASTIC_PASS'] = '******'
    dir_path = os.path.dirname(os.path.realpath(__file__))

    test_args = mock.Mock()
    test_args.config = dir_path + '/example.config.yaml'
    test_args.rule = None
    test_args.debug = True
    test_args.verbose = True
    test_args.es_debug_trace = None

    load_conf(test_args)

    expected_msg = 'Note: --debug and --verbose flags are set. --debug takes precedent.'
    assert ('elastalert', logging.INFO, expected_msg) == caplog.record_tuples[0]
예제 #2
0
def test_config_loads_logging(capfd):
    os.environ['ELASTIC_PASS'] = '******'
    dir_path = os.path.dirname(os.path.realpath(__file__))

    test_args = mock.Mock()
    test_args.config = dir_path + '/example.config.logging.yaml'
    test_args.rule = None
    test_args.debug = True
    test_args.verbose = True
    test_args.es_debug_trace = None

    load_conf(test_args)

    expected1 = 'Note: --debug and --verbose flags are set. --debug takes precedent.'
    expected2 = 'Note: In debug mode, alerts will be logged to console but NOT actually sent.\n'
    expected3 = '           To send them but remain verbose, use --verbose instead.\n'
    out, err = capfd.readouterr()
    assert expected1 in err
    assert expected2 in err
    assert expected3 in err