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