# Path: replayenhancer/AdditionalParticipantPacket.py
# class AdditionalParticipantPacket(Packet):
#     """
#     Creates an object from an additional participant info string
#     packet.
# 
#     The additional participant info string packet has a length of
#     1028, and is packet type 2.
#     """
#     def __init__(self, packet_data):
#         self.data_hash = md5(packet_data).hexdigest()
#         unpacked_data = self._unpack_data(packet_data)
# 
#         try:
#             self.build_version_number = int(unpacked_data.popleft())
# 
#             self._test_packet_type(unpacked_data.popleft())
# 
#             self.offset = int(unpacked_data.popleft())
# 
#             self.name = list()
#             for _ in range(16):
#                 self.name.append(
#                     str(
#                         unpacked_data.popleft(),
#                         encoding='utf-8',
#                         errors='strict').split('\x00', 1)[0])
# 
#         except ValueError:
#             raise
# 
#     @property
#     def packet_type(self):
#         return 2
# 
#     @property
#     def _packet_string(self):
#         packet_string = "HBB"
#         packet_string += "64s"*16
# 
#         return packet_string
# 
#     def __str__(self):
#         return "AdditionalParticipantPacket"


import unittest
from hashlib import md5
from struct import pack
from replayenhancer.AdditionalParticipantPacket \
    import AdditionalParticipantPacket
        from struct import error

    def binary_data(cls, **kwargs):
        test_data = list()
        packet_string = "HBB"
        packet_string += "64s"*16

        try:
            test_data.append(kwargs['build_version_number'])
        except KeyError:
            test_data.append(cls.expected_build_version_number)

        try:
            test_data.append(kwargs['packet_type'])
        except KeyError:
            test_data.append(cls.expected_packet_type)

        try:
            test_data.append(kwargs['offset'])
        except KeyError:
            test_data.append(cls.expected_offset)

        try:
            test_data.extend([name.encode('utf-8') for name in kwargs['name']])
        except KeyError:
            test_data.extend(
                [name.encode('utf-8') for name in cls.expected_name])

        return pack(packet_string, *test_data)

    def test_init(self):
        instance = AdditionalParticipantPacket(self.binary_data())

# Path: replayenhancer/AdditionalParticipantPacket.py
# class AdditionalParticipantPacket(Packet):
#     """
#     Creates an object from an additional participant info string
#     packet.
# 
#     The additional participant info string packet has a length of
#     1028, and is packet type 2.
#     """
#     def __init__(self, packet_data):
#         self.data_hash = md5(packet_data).hexdigest()
#         unpacked_data = self._unpack_data(packet_data)
# 
#         try:
#             self.build_version_number = int(unpacked_data.popleft())
# 
#             self._test_packet_type(unpacked_data.popleft())
# 
#             self.offset = int(unpacked_data.popleft())
# 
#             self.name = list()
#             for _ in range(16):
#                 self.name.append(
#                     str(
#                         unpacked_data.popleft(),
#                         encoding='utf-8',
#                         errors='strict').split('\x00', 1)[0])
# 
#         except ValueError:
#             raise
# 
#     @property
#     def packet_type(self):
#         return 2
# 
#     @property
#     def _packet_string(self):
#         packet_string = "HBB"
#         packet_string += "64s"*16
# 
#         return packet_string
# 
#     def __str__(self):
#         return "AdditionalParticipantPacket"


# Path: test/test_AdditionalParticipantPacket.py
import unittest
from hashlib import md5
from struct import pack
from replayenhancer.AdditionalParticipantPacket \
    import AdditionalParticipantPacket
        from struct import error

    def binary_data(cls, **kwargs):
        test_data = list()
        packet_string = "HBB"
        packet_string += "64s"*16

        try:
            test_data.append(kwargs['build_version_number'])
        except KeyError:
            test_data.append(cls.expected_build_version_number)

        try:
            test_data.append(kwargs['packet_type'])
        except KeyError:
            test_data.append(cls.expected_packet_type)

        try:
            test_data.append(kwargs['offset'])
        except KeyError:
            test_data.append(cls.expected_offset)

        try:
            test_data.extend([name.encode('utf-8') for name in kwargs['name']])
        except KeyError:
            test_data.extend(
                [name.encode('utf-8') for name in cls.expected_name])

        return pack(packet_string, *test_data)

    def test_init(self):
        instance = AdditionalParticipantPacket(self.binary_data())

        expected_result = AdditionalParticipantPacket
