コード例 #1
0
 def test_stop(self):
     s = self._socket()
     c = Connection(s)
     c.stop()
     # no packets should ever be returned after stoping
     # and it should return instantly
     eq_(list(c.packets()), [])
コード例 #2
0
    def test_send_packet_escaping(self):
        stream = six.BytesIO()
        c = Connection(stream)

        c.send_packet(1, """"Hello World""" "")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\x0f"\\"Hello World"'))
コード例 #3
0
 def test_stop(self):
     s = self._socket()
     c = Connection(s)
     c.stop()
     # no packets should ever be returned after stoping
     # and it should return instantly
     eq_(list(c.packets()), [])
コード例 #4
0
    def test_send_packet_escaping(self):
        stream = six.BytesIO()
        c = Connection(stream)

        c.send_packet(1, """"Hello World""""")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\x0f"\\"Hello World"'))
コード例 #5
0
    def test_send_packet(self):
        stream = six.BytesIO()

        c = Connection(stream)

        c.send_packet(1, "Hello World")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\r"Hello World"'))
コード例 #6
0
    def test_send_packet(self):
        stream = six.BytesIO()

        c = Connection(stream)

        c.send_packet(1, "Hello World")
        eq_(stream.getvalue(),
            six.b('\x01\x01\x00\x00\x00\x00\x00\r"Hello World"'))
コード例 #7
0
    def test_packets(self):
        s, stream = self._with_data(self._dummy_msg)

        c = Connection(s)

        kind, body = six.next(c.packets())

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(self._dummy_msg))
コード例 #8
0
    def test_wrong_version(self):
        # Just a header, just reading the invalid
        # number causes an exception.
        # Version = 99, type = 1 len= 5
        msg = six.b('c\x01\x00\x00\x00\x00\x00\x05')
        s, stream = self._with_data(msg)

        c = Connection(s)

        c.read_packet()
コード例 #9
0
    def test_packets(self):
        s, stream = self._with_data(self._dummy_msg)

        c = Connection(s)

        kind, body = six.next(c.packets())

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(self._dummy_msg))
コード例 #10
0
    def test_wrong_version(self):
        # Just a header, just reading the invalid
        # number causes an exception.
        # Version = 99, type = 1 len= 5
        msg = six.b('c\x01\x00\x00\x00\x00\x00\x05')
        s, stream = self._with_data(msg)

        c = Connection(s)

        c.read_packet()
コード例 #11
0
    def test_read_packet(self):
        s = self._socket()
        # Version = 1, type = 't', len = 31
        msg = self._dummy_msg

        s, stream = self._with_data(msg)

        c = Connection(s)

        kind, body = c.read_packet()

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(msg))
コード例 #12
0
    def test_read_packet(self):
        s = self._socket()
        # Version = 1, type = 't', len = 31
        msg = self._dummy_msg

        s, stream = self._with_data(msg)

        c = Connection(s)

        kind, body = c.read_packet()

        eq_(kind, 116)
        eq_(body, "Hello World")
        eq_(stream.tell(), len(msg))
コード例 #13
0
    def test_start_with_socket(self):
        import gevent.socket as s
        mck = Mock(spec=s.socket)

        c = Connection(mck)

        mck.makefile.assert_called_once()
コード例 #14
0
    def _start(self):
        serv, cli, clifd = get_sockets()
        secret = "__NO_AUTH__"
        if self._secured:  # pragma: nocover
            raise RuntimeError("Secure connections are not supported yet")

        self._proc = open_process(clifd, secret)
        self._con = Connection(serv)
        self._proto = Protocol(self._con,
                               None if not self._secured else secret)
        self._proto.start()
コード例 #15
0
    def test_no_packets(self):
        s = self._socket()
        s.closed = True
        c = Connection(s)

        six.next(c.packets())
コード例 #16
0
    def test_no_packets(self):
        s = self._socket()
        s.closed = True
        c = Connection(s)

        six.next(c.packets())