def test_send_string(self): from pyramid_sockjs import Session, protocol session = Session('id') session.manager = _SM() session.send('message') self.assertEqual(session.queue.get(), 'message')
def test_send_tick(self): from pyramid_sockjs import Session, protocol session = Session('id') self.now = self.now + timedelta(hours=1) session.send(['message']) self.assertEqual(session.expires, self.now + session.timeout)
def test_send_tick(self): from pyramid_sockjs import Session, protocol session = Session('id') session.manager = _SM() self.now = self.now + timedelta(hours=1) session.send(['message']) self.assertEqual(session.expires, self.now + session.timeout)
def test_get_transport_message_tick(self): from pyramid_sockjs import Session session = Session('id') session.send('message') self.now = self.now + timedelta(hours=1) session.get_transport_message() self.assertEqual(session.expires, self.now + session.timeout)
def test_get_transport_message(self): from pyramid_sockjs import Session session = Session('id') session.send('message') self.assertEqual(session.get_transport_message(), 'message') from gevent.queue import Empty self.assertRaises( Empty, session.get_transport_message, timeout=0.1)
def test_get_transport_message(self): from pyramid_sockjs import Session session = Session('id') session.manager = _SM() session.send('message') self.assertEqual(session.get_transport_message(), 'message') from gevent.queue import Empty self.assertRaises(Empty, session.get_transport_message, timeout=0.1)
def test_get_transport_message_tick(self): from pyramid_sockjs import Session session = Session('id') session.manager = _SM() session.send('message') self.now = self.now + timedelta(hours=1) session.get_transport_message() self.assertEqual(session.expires, self.now + session.timeout)
def test_str(self): from pyramid_sockjs import Session, STATE_OPEN, STATE_CLOSING session = Session('test') session.hits = 10 session.heartbeats = 50 session.state = STATE_OPEN self.assertEqual(str(session), "id='test' connected hits=10 heartbeats=50") session.state = STATE_CLOSING self.assertEqual(str(session), "id='test' disconnected hits=10 heartbeats=50") session.send('msg') self.assertEqual( str(session), "id='test' disconnected queue[1] hits=10 heartbeats=50")
def test_str(self): from pyramid_sockjs import Session, STATE_OPEN, STATE_CLOSING session = Session('test') session.hits = 10 session.heartbeats = 50 session.state = STATE_OPEN session.manager = _SM() self.assertEqual(str(session), "id='test' connected hits=10 heartbeats=50") session.state = STATE_CLOSING self.assertEqual(str(session), "id='test' disconnected hits=10 heartbeats=50") session.send('msg') self.assertEqual( str(session), "id='test' disconnected queue[1] hits=10 heartbeats=50")
def test_send(self): from pyramid_sockjs import Session, protocol session = Session('id') session.send(['message']) self.assertEqual(session.queue.get(), ['message'])