Files
Hippolyzer/pyogp/lib/base/message/tests/test_udp_serializer.py
tao.takashi 6a6dd5fdb1 The big message system renaming:
- renamed all files starting with message_ to a name without message_
- exception: msgdict as dict is a reserved word
- moved all tests into the message/ directory
- changed all tests to use the new names
- changed all modules to use the new names
- shortened imports to not use the full path (pyogp.lib.base. but only the short path)
- removed makepacketdict.py as it's not needed anymore
- moved the data/ directory into message/ as it's local to the msg system

and some small cleanups on the way.

please run the tests!

I haven't adjusted pyogp.interop yet, Enus wanted to look after it.
2008-09-03 22:55:07 +00:00

41 lines
1.2 KiB
Python

#standard libraries
import unittest, doctest
from uuid import UUID
#local libraries
from pyogp.lib.base.message.types import MsgType
from pyogp.lib.base.message.interfaces import IPacket
from pyogp.lib.base.interfaces import ISerialization, IDeserialization
from pyogp.lib.base.registration import init
#from indra.base.lluuid import UUID
class TestSerializer(unittest.TestCase):
def tearDown(self):
pass
def setUp(self):
init()
def test_serialize(self):
message = '\xff\xff\xff\xfb' + '\x03' + \
'\x01\x00\x00\x00' + '\x02\x00\x00\x00' + '\x03\x00\x00\x00'
message = '\x00' + '\x00\x00\x00\x01' +'\x00' + message
deserializer = IDeserialization(message)
packet = deserializer.deserialize()
#print packet.send_flags
#print packet.packet_id
data = packet.message_data
serializer = ISerialization(packet)
packed_data = serializer.serialize()
assert packed_data == message, "Incorrect serialization"
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestSerializer))
return suite