Esempio n. 1
0
def test_dummyclient_basic(no_network):
    client = statsd.DummyClient()

    # check the basic methods don't error or use network
    client.incr('a')
    client.decr('a')
    client.timing('a', 1)
    client.gauge('a', 1)
    client.set('a', 1)
    timer = client.timer('a')
    timer.start()
    timer.stop()
Esempio n. 2
0
def test_dummyclient_collect(no_network):
    client = statsd.DummyClient()
    with client.collect() as stats:
        client.incr('a')
        client.decr('a')
        client.timing('a', 1)
        client.gauge('a', 1)
        client.set('a', 1)
        timer = client.timer('a')
        timer.start()
        timer.stop()

        assert stats[0] == 'a:1|c'
        assert stats[1] == 'a:-1|c'
        assert stats[2] == 'a:1.000000|ms'
        assert stats[3] == 'a:1|g'
        assert stats[4] == 'a:1|s'
        assert stats[5].startswith('a:')
        assert stats[5].endswith('|ms')
Esempio n. 3
0
def test_dummyclient_pipeline(no_network):
    client = statsd.DummyClient()
    with client.pipeline() as p:
        p.incr('a')
        p.decr('a')
        p.timing('a', 1)
        p.gauge('a', 1)
        p.set('a', 1)
        timer = p.timer('a')
        timer.start()
        timer.stop()

        assert p.stats[0] == 'a:1|c'
        assert p.stats[1] == 'a:-1|c'
        assert p.stats[2] == 'a:1.000000|ms'
        assert p.stats[3] == 'a:1|g'
        assert p.stats[4] == 'a:1|s'
        assert p.stats[5].startswith('a:')
        assert p.stats[5].endswith('|ms')
Esempio n. 4
0
def test_dummyclient_nested_pipeline(no_network):
    client = statsd.DummyClient()
    with client.pipeline() as p1:
        with p1.pipeline() as p2:
            assert p1.stats is not p2.stats
Esempio n. 5
0
def test_dummyclient_memory(no_network):
    client = statsd.DummyClient()
    assert client.stats is None
    for i in range(1000):
        client.incr('a')
    assert client.stats is None