[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Add tests for stem.response.events.Event



commit 26a39c9ac5bf77860f2a10dd776c95ce46ef6380
Author: Sean Robinson <seankrobinson@xxxxxxxxx>
Date:   Fri Dec 14 14:13:38 2012 -0700

    Add tests for stem.response.events.Event
    
    This tests the base class used to build named event classes (e.g. ADDRMAP,
    BW, CIRC, etc.).  Mainly this documents existing behavior so we can
    check future changes to the class do not surprise us with breakage.
    
    Signed-off-by: Sean Robinson <seankrobinson@xxxxxxxxx>
---
 test/unit/response/events.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index 1a40958..91eaa18 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -235,6 +235,16 @@ class TestEvents(unittest.TestCase):
     time.sleep(0.2)
     events_thread.join()
   
+  def test_event(self):
+    # synthetic, contrived message construction to reach the blank event check
+    self.assertRaises(ProtocolError, stem.response.convert, "EVENT", stem.response.ControlMessage([('', '', '')], ''), arrived_at = 25)
+    
+    # Event._parse_message() on an unknown event type
+    event = _get_event('650 NONE SOLID "NON SENSE" condition=MEH quoted="1 2 3"')
+    self.assertEqual("NONE", event.type)
+    self.assertEqual(["SOLID", '"NON', 'SENSE"'], event.positional_args)
+    self.assertEqual({"condition":"MEH", "quoted":"1 2 3"}, event.keyword_args)
+  
   def test_log_events(self):
     event = _get_event("650 DEBUG connection_edge_process_relay_cell(): Got an extended cell! Yay.")
     



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits