# Path: zoonado/protocol/request.py
# class Request(Part):
#     def serialize(self, xid=None):
# 
# Path: zoonado/protocol/primitives.py
# class Primitive(object):
# class VariablePrimitive(Primitive):
# class Bool(Primitive):
# class Byte(Primitive):
# class Int(Primitive):
# class Long(Primitive):
# class Float(Primitive):
# class Double(Primitive):
# class UString(VariablePrimitive):
# class Buffer(VariablePrimitive):
# class Vector(Primitive):
#     def __init__(self, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def of(cls, part_class):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __str__(self):


import unittest
from mock import patch
from zoonado.protocol import request, primitives

        mock_struct.pack.assert_called_once_with("!ii6s", 3, 6, b'foobar')

    @patch.object(request, "struct")
    def test_serialize_with_xid(self, mock_struct):
        mock_struct.pack.return_value = b"fake result"

        class FakeRequest(request.Request):
            parts = (
                ("first", primitives.Int),
                ("second", primitives.UString),
            )

        r = FakeRequest(first=3, second=u"foobar")

        result = r.serialize(xid=12)

        self.assertEqual(result, b"fake result")

        mock_struct.pack.assert_called_once_with("!iii6s", 12, 3, 6, b'foobar')

    @patch.object(request, "struct")
    def test_serialize_with_xid_and_opcode(self, mock_struct):
        mock_struct.pack.return_value = b"fake result"

        class FakeRequest(request.Request):
            opcode = 99

            parts = (
                ("first", primitives.Int),

# Path: zoonado/protocol/request.py
# class Request(Part):
#     def serialize(self, xid=None):
# 
# Path: zoonado/protocol/primitives.py
# class Primitive(object):
# class VariablePrimitive(Primitive):
# class Bool(Primitive):
# class Byte(Primitive):
# class Int(Primitive):
# class Long(Primitive):
# class Float(Primitive):
# class Double(Primitive):
# class UString(VariablePrimitive):
# class Buffer(VariablePrimitive):
# class Vector(Primitive):
#     def __init__(self, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __eq__(self, other):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def render(self):
#     def parse(cls, buff, offset):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def __str__(self):
#     def render_value(self, value):
#     def parse_value(cls, value):
#     def of(cls, part_class):
#     def render(self):
#     def parse(cls, buff, offset):
#     def __str__(self):


# Path: tests/protocol/test_request.py
import unittest
from mock import patch
from zoonado.protocol import request, primitives


        mock_struct.pack.assert_called_once_with("!ii6s", 3, 6, b'foobar')

    @patch.object(request, "struct")
    def test_serialize_with_xid(self, mock_struct):
        mock_struct.pack.return_value = b"fake result"

        class FakeRequest(request.Request):
            parts = (
                ("first", primitives.Int),
                ("second", primitives.UString),
            )

        r = FakeRequest(first=3, second=u"foobar")

        result = r.serialize(xid=12)

        self.assertEqual(result, b"fake result")

        mock_struct.pack.assert_called_once_with("!iii6s", 12, 3, 6, b'foobar')

    @patch.object(request, "struct")
    def test_serialize_with_xid_and_opcode(self, mock_struct):
        mock_struct.pack.return_value = b"fake result"

        class FakeRequest(request.Request):
            opcode = 99

            parts = (
                ("first", primitives.Int),

                ("second", primitives.UString),