def test_serializer_type(self): send_message_request = build_send_message_request('baz') serialized_req = serialize_send_message_request(send_message_request) # This seems weird, but zmq frames are a tuple so it makes sense to # use the same type but just ensure that all fields are strings. self.assertIsInstance(serialized_req, SendMessageRequestEntry) for fname in serialized_req._fields: self.assertIsInstance(getattr(serialized_req, fname), basestring)
def test_send_builder_binary(self): body = 'baz' send_message_request = build_send_message_request(body, binary=True) flags = send_message_request.MessageAttributes['flags']['StringValue'] flags = int(flags) self.assertTrue(flags & BASE64_ENCODE) self.assertTrue(flags & ZLIB_COMPRESS) message_body = compress(body).encode('base64') self.assertEqual(send_message_request.MessageBody, message_body)
def setUp(self): super(TestSendMessage, self).setUp() self.send_message_request = build_send_message_request('baz')
def test_deserializer_equality(self): send_message_request = build_send_message_request('baz') serialized_req = serialize_send_message_request(send_message_request) deserialized_req = deserialize_send_message_request(serialized_req) self.assertEqual(deserialized_req, send_message_request)
def test_deserializer_type(self): send_message_request = build_send_message_request('baz') serialized_req = serialize_send_message_request(send_message_request) deserialized_req = deserialize_send_message_request(serialized_req) self.assertIsInstance(deserialized_req, SendMessageRequestEntry)
def test_serializer_message_attributes(self): send_message_request = build_send_message_request('baz') serialized_req = serialize_send_message_request(send_message_request) self.assertEqual(serialized_req.MessageAttributes, dumps(send_message_request.MessageAttributes))
def test_send_builder_nonbinary(self): send_message_request = build_send_message_request('baz', binary=False) flags = send_message_request.MessageAttributes['flags']['StringValue'] flags = int(flags) self.assertFalse(flags & BASE64_ENCODE) self.assertFalse(flags & ZLIB_COMPRESS)
def test_send_builder_type(self): send_message_request = build_send_message_request('baz') self.assertIsInstance(send_message_request, SendMessageRequestEntry)