Exemplo n.º 1
1
    def test_protobuf_serializer(self):
        serializer = ProtobufSerializer(queueschema)

        headers, content = serializer.dump({}, protobuf)

        assert headers['Content-Type'] == 'application/x-protobuf'
        assert headers['X-Protobuf-FullName'] == protobuf.DESCRIPTOR.full_name
        assert content == protobuf.SerializeToString()
Exemplo n.º 2
0
    def test_protobuf_deserializer(self):
        serializer = ProtobufSerializer(queueschema)

        content = protobuf.SerializeToString()
        response = httplib2.Response({
            'status':
            200,
            'content-type':
            'application/x-protobuf',
            'x-protobuf-fullname':
            protobuf.DESCRIPTOR.full_name,
        })

        response, content = serializer.load(response, content)
        assert content.SerializeToString() == protobuf.SerializeToString()
Exemplo n.º 3
0
 def testHydrateProtobuf(self):
     content = protobuf.SerializeToString()
     name = protobuf.DESCRIPTOR.full_name
     testProto = self.queueConfig.hydrateProtobuf(name, content)
     self.assertEqual(testProto.uuid, protobuf.uuid)
     self.assertEqual(testProto.created_time, protobuf.created_time)
Exemplo n.º 4
0
 def test_get_message(self):
     response, content = self.client.get('test_message')
     assert response['content-type'] == 'application/x-protobuf'
     assert content.SerializeToString() == protobuf.SerializeToString()
Exemplo n.º 5
0
 def do_GET(self):
     self.send_response(200)
     self.send_header('Content-Type', 'application/x-protobuf')
     self.send_header('X-Protobuf-FullName', protobuf.DESCRIPTOR.full_name)
     self.end_headers()
     self.wfile.write(protobuf.SerializeToString())