Exemplo n.º 1
0
 def test_open_session(self):
     stream = mock.MagicMock()
     sess = session.open_session(stream)
     self.assertEqual(sess.stream, stream)
     self.open_brain_hook.assert_called_once_with(hook.HOOK_OPEN_BRAIN, sess)
Exemplo n.º 2
0
 def test_get_session_fails_after_close(self):
     stream = mock.MagicMock()
     session.open_session(stream)
     session.close_session(stream)
     self.assertRaises(KeyError, session.get_session, stream)
Exemplo n.º 3
0
 def test_close_session(self):
     stream = mock.MagicMock()
     sess1 = session.open_session(stream)
     sess2 = session.close_session(stream)
     self.assertEqual(sess1, sess2)
     self.close_brain_hook.assert_called_once_with(hook.HOOK_CLOSE_BRAIN, sess1)
Exemplo n.º 4
0
 def test_get_session_after_open(self):
     stream = mock.MagicMock()
     self.assertRaises(KeyError, session.get_session, stream)
     sess1 = session.open_session(stream)
     sess2 = session.get_session(stream)
     self.assertEqual(sess1, sess2)
Exemplo n.º 5
0
 def on_connect(self):
     log.debug("on_connect: '%s'", self)
     self.read_delimiter = "\r\n"
     session.open_session(self)