def test_setup_reporter_from_parameter(set_librato_credentials): rep = metric.setup_reporter('librato') assert isinstance(rep, reporter.LibratoReport) rep = metric.setup_reporter('direct') assert isinstance(rep, reporter.DirectReport) rep = metric.setup_reporter('dummy') assert isinstance(rep, reporter.DummyReport)
def test_set_source_from_env_setting_when_passing_none(): os.environ[ 'METRICS_SOURCE'] = 'environ_source2' # probably should cleanup, but... rep = metric.setup_reporter('librato', None) assert rep.source == 'environ_source2'
def test_set_source_from_parameter(set_librato_credentials): rep = metric.setup_reporter('librato', 'custom_source') assert rep.source == 'custom_source'
def test_setup_non_existent_reporter(): with pytest.raises(reporter.StatsReportException): rep = metric.setup_reporter('no-such-reporter')
def test_setup_reporter_defaults(set_librato_credentials): # Librato is our default without config for the moment assert isinstance(metric.setup_reporter(), reporter.LibratoReport)
def test_direct_gauge_submission(): rep = metric.setup_reporter('direct') rep.gauge("Test.SubmissionDirectCheck", 1)
def test_librato_gauge(set_librato_credentials): rep = metric.setup_reporter('librato') rep.gauge("Test.SubmissionLibratoCheck", 1)