<s> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import unittest <EOL> from ddp . messages . ping_message import PingMessage <EOL> from ddp . messages . message_serializer import MessageSerializer <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class MessageSerializerTestCase ( unittest . TestCase ) : <EOL> def test_not_implemeted ( self ) : <EOL> with self . assertRaises ( NotImplementedError ) : <EOL> MessageSerializer ( ) . serialize_fields ( PingMessage ( ) ) <EOL> def test_optimize ( self ) : <EOL> class MockMessage ( object ) : <EOL> def __init__ ( self , optimized = False ) : <EOL> self . optimized = optimized <EOL> def optimize ( self ) : <EOL> return MockMessage ( optimized = True ) <EOL> class MockMessageSerializer ( MessageSerializer ) : <EOL> MESSAGE_TYPE = '<STR_LIT>' <EOL> def serialize_fields ( self , message ) : <EOL> return { '<STR_LIT>' : message . optimized } <EOL> s1 = MockMessageSerializer ( ) <EOL> s2 = MockMessageSerializer ( optimize = True ) <EOL> self . assertFalse ( s1 . serialize ( MockMessage ( ) ) [ '<STR_LIT>' ] ) <EOL> self . assertTrue ( s2 . serialize ( MockMessage ( ) ) [ '<STR_LIT>' ] ) </s>
