Exemplo n.º 1
0
    def test_it(self):
        from google.cloud.proto.datastore.v1 import datastore_pb2
        from google.cloud.proto.datastore.v1 import entity_pb2

        index_updates = 1337
        keys = [
            entity_pb2.Key(
                path=[
                    entity_pb2.Key.PathElement(
                        kind='Foo',
                        id=1234,
                    ),
                ],
            ),
            entity_pb2.Key(
                path=[
                    entity_pb2.Key.PathElement(
                        kind='Bar',
                        name='baz',
                    ),
                ],
            ),
        ]
        response = datastore_pb2.CommitResponse(
            mutation_results=[
                datastore_pb2.MutationResult(key=key) for key in keys
            ],
            index_updates=index_updates,
        )
        result = self._call_fut(response)
        self.assertEqual(result, (index_updates, keys))
Exemplo n.º 2
0
    def __init__(self, xact_id=123, keys=()):
        from google.cloud.proto.datastore.v1 import datastore_pb2

        self._xact_id = xact_id
        mutation_results = [
            datastore_pb2.MutationResult(key=key) for key in keys
        ]
        self._commit_response_pb = datastore_pb2.CommitResponse(
            mutation_results=mutation_results)
Exemplo n.º 3
0
    def commit(self, project, commit_request, transaction_id):
        from google.cloud.proto.datastore.v1 import datastore_pb2

        self._commit_cw.append((project, commit_request, transaction_id))
        keys, self._commit = self._commit[0], self._commit[1:]
        mutation_results = [
            datastore_pb2.MutationResult(key=key) for key in keys
        ]
        return datastore_pb2.CommitResponse(mutation_results=mutation_results)
Exemplo n.º 4
0
def _make_mutation(id_):
    from google.cloud.proto.datastore.v1 import datastore_pb2
    from google.cloud.proto.datastore.v1 import entity_pb2

    key = entity_pb2.Key()
    key.partition_id.project_id = 'PROJECT'
    elem = key.path.add()
    elem.kind = 'Kind'
    elem.id = id_
    return datastore_pb2.MutationResult(key=key)
Exemplo n.º 5
0
def _make_commit_response(*keys):
    from google.cloud.proto.datastore.v1 import datastore_pb2

    mutation_results = [datastore_pb2.MutationResult(key=key) for key in keys]
    return datastore_pb2.CommitResponse(mutation_results=mutation_results)