Exemple #1
0
 def start(self, version_major, version_minor, server_properties,
           mechanisms, locales):
     args = AMQPWriter()
     args.write_octet(version_major)
     args.write_octet(version_minor)
     args.write_table(server_properties)
     args.write_longstr(' '.join(mechanisms))
     args.write_longstr(' '.join(locales))
     self._send_channel_method_frame(0, (10, 10), args)
    def test_octet(self):
        for val in range(256):
            w = AMQPWriter()
            w.write_octet(val)
            s = w.getvalue()
            self.assertEqual(s, chr(val))

            r = AMQPReader(s)
            self.assertEqual(r.read_octet(), val)
 def start(self, version_major, version_minor, server_properties,
             mechanisms, locales):
     args = AMQPWriter()
     args.write_octet(version_major)
     args.write_octet(version_minor)
     args.write_table(server_properties)
     args.write_longstr(' '.join(mechanisms))
     args.write_longstr(' '.join(locales))
     self._send_channel_method_frame(0, (10, 10), args)
    def test_octet(self):
        for val in range(256):
            w = AMQPWriter()
            w.write_octet(val)
            s = w.getvalue()
            self.assertEqual(s, chr(val))

            r = AMQPReader(s)
            self.assertEqual(r.read_octet(), val)
    def test_multiple_bits2(self):
        """
        Check bits mixed with non-bits
        """
        w = AMQPWriter()
        w.write_bit(True)
        w.write_bit(True)
        w.write_bit(False)
        w.write_octet(10)
        w.write_bit(True)
        s = w.getvalue()

        self.assertEqual(s, '\x03\x0a\x01')

        r = AMQPReader(s)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), False)
        self.assertEqual(r.read_octet(), 10)
        self.assertEqual(r.read_bit(), True)
    def test_multiple_bits2(self):
        """
        Check bits mixed with non-bits
        """
        w = AMQPWriter()
        w.write_bit(True)
        w.write_bit(True)
        w.write_bit(False)
        w.write_octet(10)
        w.write_bit(True)
        s = w.getvalue()

        self.assertEqual(s, '\x03\x0a\x01')

        r = AMQPReader(s)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), True)
        self.assertEqual(r.read_bit(), False)
        self.assertEqual(r.read_octet(), 10)
        self.assertEqual(r.read_bit(), True)