コード例 #1
0
ファイル: test_main.py プロジェクト: bmess/nagios_graphite
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
ファイル: test_main.py プロジェクト: neha-ot/nagios_graphite
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
ファイル: test_main.py プロジェクト: bmess/nagios_graphite
def test_combine_with_none():
    id_ = lambda xs: xs
    assert combine(graphite_with_none, id_) == [1, 2, 3, None, 5, None]
コード例 #4
0
ファイル: test_main.py プロジェクト: bmess/nagios_graphite
def test_combine_without_none():
    id_ = lambda xs: xs
    assert combine(graphite_without_none, id_) == [1, 2, 3, 4, 5, 6]
コード例 #5
0
ファイル: test_main.py プロジェクト: bmess/nagios_graphite
def test_combine_empty():
    assert combine([], sum) == 0
コード例 #6
0
ファイル: test_main.py プロジェクト: neha-ot/nagios_graphite
def test_combine_with_none():
    id_ = lambda xs: xs
    assert combine(graphite_with_none, id_) == [1, 2, 3, None, 5, None]
コード例 #7
0
ファイル: test_main.py プロジェクト: neha-ot/nagios_graphite
def test_combine_without_none():
    id_ = lambda xs: xs
    assert combine(graphite_without_none, id_) == [1, 2, 3, 4, 5, 6]
コード例 #8
0
ファイル: test_main.py プロジェクト: neha-ot/nagios_graphite
def test_combine_empty():
    assert combine([], sum) == 0
コード例 #9
0
def test_combine_with_none():
    assert combine(graphite_with_none, sum) == 11