summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Socol <james@bit.ly>2014-01-07 16:09:33 -0500
committerJames Socol <james@bit.ly>2014-01-07 16:09:33 -0500
commita394975e4f9537231b6e1c6ce47ab6163fc31b21 (patch)
tree89662366aa0af959b8a412b10a9a3745be629a4c
parentff0365e05a6390d43faa9462b1af261f247d286b (diff)
downloadpystatsd-a394975e4f9537231b6e1c6ce47ab6163fc31b21.tar.gz
Close gaps in client coverage.
-rw-r--r--statsd/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/statsd/tests.py b/statsd/tests.py
index c5d9ce9..fc51af5 100644
--- a/statsd/tests.py
+++ b/statsd/tests.py
@@ -348,6 +348,19 @@ def test_timer_object_no_send_twice():
t.send()
+def test_timer_send_without_stop():
+ sc = _client()
+ with sc.timer('foo') as t:
+ assert t.ms is None
+ with assert_raises(RuntimeError):
+ t.send()
+
+ t = sc.timer('bar').start()
+ assert t.ms is None
+ with assert_raises(RuntimeError):
+ t.send()
+
+
def test_timer_object_stop_without_start():
sc = _client()
with assert_raises(RuntimeError):
@@ -456,3 +469,17 @@ def test_big_numbers():
for method, suffix in tests:
yield _check, method, suffix
+
+
+@mock.patch.object(random, 'random', lambda: 2)
+def test_rate_no_send():
+ sc = _client()
+ sc.incr('foo', rate=0.5)
+ _sock_check(sc, 0)
+
+
+def test_socket_error():
+ sc = _client()
+ sc._sock.sendto.side_effect = socket.timeout()
+ sc.incr('foo')
+ _sock_check(sc, 1, 'foo:1|c')