示例#1
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
示例#2
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
示例#3
0
def test_combine_with_none():
    id_ = lambda xs: xs
    assert combine(graphite_with_none, id_) == [1, 2, 3, None, 5, None]
示例#4
0
def test_combine_without_none():
    id_ = lambda xs: xs
    assert combine(graphite_without_none, id_) == [1, 2, 3, 4, 5, 6]
示例#5
0
def test_combine_empty():
    assert combine([], sum) == 0
示例#6
0
def test_combine_with_none():
    id_ = lambda xs: xs
    assert combine(graphite_with_none, id_) == [1, 2, 3, None, 5, None]
示例#7
0
def test_combine_without_none():
    id_ = lambda xs: xs
    assert combine(graphite_without_none, id_) == [1, 2, 3, 4, 5, 6]
示例#8
0
def test_combine_empty():
    assert combine([], sum) == 0
示例#9
0
def test_combine_with_none():
    assert combine(graphite_with_none, sum) == 11