Browse files

Adding tests for zmq.session.

  • Loading branch information...
1 parent d86d45f commit a09b42a41b65684a0706cc802489149e4f65a031 @ellisonbg ellisonbg committed Jul 14, 2011
Showing with 14 additions and 3 deletions.
  1. +1 −1 IPython/zmq/session.py
  2. +13 −2 IPython/zmq/tests/test_session.py
View
2 IPython/zmq/session.py
@@ -436,7 +436,7 @@ def serialize(self, msg, ident=None):
return to_send
- def send(self, stream, msg_or_type, content=None, parent=None, ident=None
+ def send(self, stream, msg_or_type, content=None, parent=None, ident=None,
buffers=None, subheader=None, track=False, header=None):
"""Build and send a message via stream or socket.
View
15 IPython/zmq/tests/test_session.py
@@ -31,14 +31,24 @@ class TestSession(SessionTestCase):
def test_msg(self):
"""message format"""
msg = self.session.msg('execute')
- thekeys = set('header msg_id parent_header msg_type content'.split())
+ thekeys = set('header parent_header content'.split())
s = set(msg.keys())
self.assertEquals(s, thekeys)
self.assertTrue(isinstance(msg['content'],dict))
self.assertTrue(isinstance(msg['header'],dict))
self.assertTrue(isinstance(msg['parent_header'],dict))
self.assertEquals(msg['header']['msg_type'], 'execute')
-
+
+ def test_serialize(self):
+ msg = self.session.msg('execute')
+ msg_list = self.session.serialize(msg, ident=b'foo')
+ ident, msg_list = self.session.feed_identities(msg_list)
+ new_msg = self.session.unserialize(msg_list)
+ self.assertEquals(ident[0], b'foo')
+ self.assertEquals(new_msg['header'],msg['header'])
+ self.assertEquals(new_msg['content'],msg['content'])
+ self.assertEquals(new_msg['parent_header'],msg['parent_header'])
+
def test_args(self):
"""initialization arguments for Session"""
s = self.session
@@ -107,3 +117,4 @@ def test_feed_identities(self):
content = dict(code='whoda',stuff=object())
themsg = self.session.msg('execute',content=content)
pmsg = theids
+

0 comments on commit a09b42a

Please sign in to comment.