Ejemplo n.º 1
0
 def test_handle_message_ready_reply_with_comm_id(self):
     def assert_ready(msg):
         decoded = json.loads(msg)
         self.assertEqual(decoded, {'msg_type': "Ready", 'content': '',
                                    'comm_id': 'Testing id'})
     comm = Comm(None, id='Test')
     comm.send = assert_ready
     comm._handle_msg({'comm_id': 'Testing id'})
Ejemplo n.º 2
0
 def test_handle_message_ready_reply_with_comm_id(self):
     def assert_ready(msg):
         decoded = json.loads(msg)
         self.assertEqual(decoded, {'msg_type': "Ready", 'content': '',
                                    'comm_id': 'Testing id'})
     comm = Comm(None, id='Test')
     comm.send = assert_ready
     comm._handle_msg({'comm_id': 'Testing id'})
Ejemplo n.º 3
0
 def test_handle_message_error_reply(self):
     def raise_error(msg):
         raise Exception('Test')
     def assert_error(msg):
         decoded = json.loads(msg)
         self.assertEqual(decoded['msg_type'], "Error")
         self.assertTrue(decoded['traceback'].endswith('Exception: Test'))
     comm = Comm(None, id='Test', on_msg=raise_error)
     comm.send = assert_error
     comm._handle_msg({})
Ejemplo n.º 4
0
    def test_handle_message_ready_reply(self):
        def assert_ready(msg):
            self.assertEqual(json.loads(msg), {
                'msg_type': "Ready",
                'content': ''
            })

        comm = Comm(None, id='Test')
        comm.send = assert_ready
        comm._handle_msg({})
Ejemplo n.º 5
0
 def test_handle_message_error_reply(self):
     def raise_error(msg):
         raise Exception('Test')
     def assert_error(msg):
         decoded = json.loads(msg)
         self.assertEqual(decoded['msg_type'], "Error")
         self.assertTrue(decoded['traceback'].endswith('Exception: Test'))
     comm = Comm(None, id='Test', on_msg=raise_error)
     comm.send = assert_error
     comm._handle_msg({})
Ejemplo n.º 6
0
 def test_handle_message_ready_reply(self):
     def assert_ready(msg):
         self.assertEqual(json.loads(msg), {'msg_type': "Ready", 'content': ''})
     comm = Comm(None, id='Test')
     comm.send = assert_ready
     comm._handle_msg({})
Ejemplo n.º 7
0
 def test_decode(self):
     msg = 'Test'
     self.assertEqual(Comm.decode(msg), msg)
Ejemplo n.º 8
0
 def test_init_comm(self):
     Comm(None)
Ejemplo n.º 9
0
 def test_decode(self):
     msg = 'Test'
     self.assertEqual(Comm.decode(msg), msg)
Ejemplo n.º 10
0
 def test_init_comm_id(self):
     comm = Comm(None, id='Test')
     self.assertEqual(comm.id, 'Test')