##// END OF EJS Templates
Adding tests for zmq.session.
Brian E. Granger -
Show More
@@ -436,7 +436,7 b' class Session(Configurable):'
436
436
437 return to_send
437 return to_send
438
438
439 def send(self, stream, msg_or_type, content=None, parent=None, ident=None
439 def send(self, stream, msg_or_type, content=None, parent=None, ident=None,
440 buffers=None, subheader=None, track=False, header=None):
440 buffers=None, subheader=None, track=False, header=None):
441 """Build and send a message via stream or socket.
441 """Build and send a message via stream or socket.
442
442
@@ -31,14 +31,24 b' class TestSession(SessionTestCase):'
31 def test_msg(self):
31 def test_msg(self):
32 """message format"""
32 """message format"""
33 msg = self.session.msg('execute')
33 msg = self.session.msg('execute')
34 thekeys = set('header msg_id parent_header msg_type content'.split())
34 thekeys = set('header parent_header content'.split())
35 s = set(msg.keys())
35 s = set(msg.keys())
36 self.assertEquals(s, thekeys)
36 self.assertEquals(s, thekeys)
37 self.assertTrue(isinstance(msg['content'],dict))
37 self.assertTrue(isinstance(msg['content'],dict))
38 self.assertTrue(isinstance(msg['header'],dict))
38 self.assertTrue(isinstance(msg['header'],dict))
39 self.assertTrue(isinstance(msg['parent_header'],dict))
39 self.assertTrue(isinstance(msg['parent_header'],dict))
40 self.assertEquals(msg['header']['msg_type'], 'execute')
40 self.assertEquals(msg['header']['msg_type'], 'execute')
41
41
42 def test_serialize(self):
43 msg = self.session.msg('execute')
44 msg_list = self.session.serialize(msg, ident=b'foo')
45 ident, msg_list = self.session.feed_identities(msg_list)
46 new_msg = self.session.unserialize(msg_list)
47 self.assertEquals(ident[0], b'foo')
48 self.assertEquals(new_msg['header'],msg['header'])
49 self.assertEquals(new_msg['content'],msg['content'])
50 self.assertEquals(new_msg['parent_header'],msg['parent_header'])
51
42 def test_args(self):
52 def test_args(self):
43 """initialization arguments for Session"""
53 """initialization arguments for Session"""
44 s = self.session
54 s = self.session
@@ -107,3 +117,4 b' class TestSession(SessionTestCase):'
107 content = dict(code='whoda',stuff=object())
117 content = dict(code='whoda',stuff=object())
108 themsg = self.session.msg('execute',content=content)
118 themsg = self.session.msg('execute',content=content)
109 pmsg = theids
119 pmsg = theids
120
General Comments 0
You need to be logged in to leave comments. Login now