Esempio n. 1
0
def test_check_graphite_failure():
    for fn_name, aggfn in FUNCTIONS.iteritems():
        opts = options_for(
            "-M 'cpu.load.average' -H http://example.com -U foo -P pass "
            "-A {}".format(fn_name))
        url_re = re.compile("^{}.*$".format(re.escape(opts.hostname)))

        responses.add(responses.GET, url_re, status=500)

        assert main.check_graphite(opts) is None
Esempio n. 2
0
def test_check_graphite_failure():
    for fn_name, aggfn in FUNCTIONS.iteritems():
        opts = options_for(
            "-M 'cpu.load.average' -H http://example.com -U foo -P pass "
            "-A {}".format(fn_name))
        url_re = re.compile("^{}.*$".format(re.escape(opts.hostname)))

        responses.add(
            responses.GET, url_re, status=500)

        assert main.check_graphite(opts) is None
Esempio n. 3
0
def test_check_graphite_success():
    for fn_name, aggfn in FUNCTIONS.iteritems():
        opts = options_for(
            "-M 'cpu.load.average' -H http://example.com -U foo -P pass "
            "-A {}".format(fn_name))
        url_re = re.compile("^{}.*$".format(re.escape(opts.hostname)))

        resp = json.dumps(graphite_with_none)
        responses.add(
            responses.GET, url_re,
            body=resp, status=200,
            content_type='application/json')

        expected = main.combine(graphite_with_none, aggfn)
        assert main.check_graphite(opts) == expected
Esempio n. 4
0
def test_check_graphite_success():
    for fn_name, aggfn in FUNCTIONS.iteritems():
        opts = options_for(
            "-M 'cpu.load.average' -H http://example.com -U foo -P pass "
            "-A {}".format(fn_name))
        url_re = re.compile("^{}.*$".format(re.escape(opts.hostname)))

        resp = json.dumps(graphite_with_none)
        responses.add(responses.GET,
                      url_re,
                      body=resp,
                      status=200,
                      content_type='application/json')

        expected = main.combine(graphite_with_none, aggfn)
        assert main.check_graphite(opts) == expected
Esempio n. 5
0
def test_raising_aggregators():
    for name, fn in FUNCTIONS.iteritems():
        with pytest.raises(main.EmptyQueryResult):
            fn([])
Esempio n. 6
0
def test_raising_aggregators():
    for name, fn in FUNCTIONS.iteritems():
        with pytest.raises(main.EmptyQueryResult):
            fn([])