~ubuntuone-pqm-team/python-statsd/stable

« back to all changes in this revision

Viewing changes to statsd/tests.py

  • Committer: James Socol
  • Date: 2014-01-07 21:09:33 UTC
  • Revision ID: git-v1:a394975e4f9537231b6e1c6ce47ab6163fc31b21
Close gaps in client coverage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
        t.send()
349
349
 
350
350
 
 
351
def test_timer_send_without_stop():
 
352
    sc = _client()
 
353
    with sc.timer('foo') as t:
 
354
        assert t.ms is None
 
355
        with assert_raises(RuntimeError):
 
356
            t.send()
 
357
 
 
358
    t = sc.timer('bar').start()
 
359
    assert t.ms is None
 
360
    with assert_raises(RuntimeError):
 
361
        t.send()
 
362
 
 
363
 
351
364
def test_timer_object_stop_without_start():
352
365
    sc = _client()
353
366
    with assert_raises(RuntimeError):
456
469
 
457
470
    for method, suffix in tests:
458
471
        yield _check, method, suffix
 
472
 
 
473
 
 
474
@mock.patch.object(random, 'random', lambda: 2)
 
475
def test_rate_no_send():
 
476
    sc = _client()
 
477
    sc.incr('foo', rate=0.5)
 
478
    _sock_check(sc, 0)
 
479
 
 
480
 
 
481
def test_socket_error():
 
482
    sc = _client()
 
483
    sc._sock.sendto.side_effect = socket.timeout()
 
484
    sc.incr('foo')
 
485
    _sock_check(sc, 1, 'foo:1|c')