[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Add unit test for STREAM_BW event handler
commit b3d91930be616ad7b7de10e3bbe581637583202c
Author: Sean Robinson <seankrobinson@xxxxxxxxx>
Date: Sat Dec 1 13:50:48 2012 -0700
Add unit test for STREAM_BW event handler
Signed-off-by: Sean Robinson <seankrobinson@xxxxxxxxx>
---
test/unit/response/events.py | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index a977627..622c480 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -864,4 +864,26 @@ class TestEvents(unittest.TestCase):
self.assertEqual("127.0.0.1", event.source_address)
self.assertEqual(15297, event.source_port)
self.assertEqual(StreamPurpose.DNS_REQUEST, event.purpose)
+
+ def test_stream_bw_event(self):
+ event = _get_event("650 STREAM_BW 2 15 25")
+
+ self.assertTrue(isinstance(event, stem.response.events.StreamBwEvent))
+ self.assertEqual("2", event.id)
+ self.assertEqual(15, event.written)
+ self.assertEqual(25, event.read)
+
+ event = _get_event("650 STREAM_BW Stream02 0 0")
+ self.assertEqual("Stream02", event.id)
+ self.assertEqual(0, event.written)
+ self.assertEqual(0, event.read)
+
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 2")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 2 15")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW - 15 25")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 12345678901234567 15 25")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 2 -15 25")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 2 15 -25")
+ self.assertRaises(ProtocolError, _get_event, "650 STREAM_BW 2 x 25")
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits