Ejemplo n.º 1
0
    def test_write_frame(self):
        args = mock()
        expect(args.buffer).returns('hello')

        frame = MethodFrame(42, 5, 6, args)
        buf = bytearray()
        frame.write_frame(buf)

        reader = Reader(buf)
        assert_equals(1, reader.read_octet())
        assert_equals(42, reader.read_short())
        size = reader.read_long()
        start_pos = reader.tell()
        assert_equals(5, reader.read_short())
        assert_equals(6, reader.read_short())
        args_pos = reader.tell()
        assert_equals('hello', reader.read(size - (args_pos - start_pos)))
        assert_equals(0xce, reader.read_octet())