Пример #1
0
    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')
Пример #2
0
    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')
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    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")
Пример #10
0
    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")
Пример #11
0
    def test_send(self):
        from pyramid_sockjs import Session, protocol
        session = Session('id')

        session.send(['message'])
        self.assertEqual(session.queue.get(), ['message'])