def testMessageClass(self): from tests.integrate_tests.msg_log import Message from tests.integrate_tests.game_log import log _log, _side_log = Message.game_log_from_import(log()) # with open(os.path.dirname(__file__) + '/../integrate_tests/fixtures/l2/game_log_15122012', 'r') as f: message_client = Message('client', log=_log, side_log=_side_log) message_server = Message('server', log=_log, side_log=_side_log) self.assertTrue(b''.join(message_client(b'')) == b''.join(_log[0:2])) self.assertTrue(b''.join(message_server(_log[0+7])) == _log[1+7]) self.assertTrue(b''.join(message_client(_log[1+7])) == _log[2+7]) self.assertTrue(b''.join(message_server(_log[2+7])) == b''.join(_log[3+7:4+1+7])) self.assertTrue(b''.join(message_client(b''.join(_log[3+7:4+1+7]))) == b''.join(_log[5+7:6+1+7]))
def test_repr_to_bytes(self): from tests.integrate_tests.msg_log import Message f = os.path.dirname(__file__) + '/../integrate_tests/fixtures/l2/game_log_15122012' pattern = {'c': b'C-', 's': b'S-', 'start': 6, 'end': -2} log = Message.get_log_from_file(f, pattern)