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
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
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_raising_aggregators(): for name, fn in FUNCTIONS.iteritems(): with pytest.raises(main.EmptyQueryResult): fn([])