class ConnectMessageSerializerTestCase(unittest.TestCase):
    def setUp(self):
        self.serializer = ConnectMessageSerializer()
        self.version = 'pre2'
        self.support = ['pre2', 'pre1']
        self.session = 'session'

    def test_with_support_with_session(self):
        message = ConnectMessage(self.version, support=self.support,
                                 session=self.session)
        pod = self.serializer.serialize(message)
        expected = {'msg': 'connect', 'version': self.version,
                    'support': self.support, 'session': self.session}
        self.assertEqual(pod, expected)

    def test_with_support_without_session(self):
        message = ConnectMessage(self.version, support=self.support)
        expected = {'msg': 'connect', 'version': self.version,
                    'support': self.support}
        pod = self.serializer.serialize(message)
        self.assertEqual(pod, expected)

    def test_without_support_with_session(self):
        message = ConnectMessage(self.version, session=self.session)
        expected = {'msg': 'connect', 'version': self.version,
                    'support': [self.version], 'session': self.session}
        pod = self.serializer.serialize(message)
        self.assertEqual(pod, expected)

    def test_without_support_without_session(self):
        message = ConnectMessage(self.version)
        pod = self.serializer.serialize(message)
        self.assertEqual(pod, {'msg': 'connect', 'version': self.version,
                               'support': [self.version]})
 def setUp(self):
     self.serializer = ConnectMessageSerializer()
     self.version = 'pre2'
     self.support = ['pre2', 'pre1']
     self.session = 'session'