Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def _set_read_options(self, request, eventual):
if eventual:
opts.read_consistency = datastore_pb.ReadOptions.EVENTUAL
elif transaction:
opts.transaction = transaction
opts.transaction = transaction.id()


def _copy_deferred_keys(lookup_request, lookup_response):
Expand Down
17 changes: 13 additions & 4 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_lookup_single_key_empty_response_w_eventual_and_transaction(self):
TRANSACTION = 'TRANSACTION'
key_pb = Key(path=[{'kind': 'Kind', 'id': 1234}]).to_protobuf()
conn = self._makeOne()
conn.transaction(TRANSACTION)
conn.transaction(Transaction(TRANSACTION))
self.assertRaises(
ValueError, conn.lookup, DATASET_ID, key_pb, eventual=True)

Expand All @@ -281,7 +281,7 @@ def test_lookup_single_key_empty_response_w_transaction(self):
key_pb = Key(path=[{'kind': 'Kind', 'id': 1234}]).to_protobuf()
rsp_pb = datastore_pb.LookupResponse()
conn = self._makeOne()
conn.transaction(TRANSACTION)
conn.transaction(Transaction(TRANSACTION))
URI = '/'.join([
conn.API_BASE_URL,
'datastore',
Expand Down Expand Up @@ -569,7 +569,7 @@ def test_run_query_wo_eventual_w_transaction(self):
rsp_pb.batch.more_results = no_more
rsp_pb.batch.entity_result_type = datastore_pb.EntityResult.FULL
conn = self._makeOne()
conn.transaction(TRANSACTION)
conn.transaction(Transaction(TRANSACTION))
URI = '/'.join([
conn.API_BASE_URL,
'datastore',
Expand Down Expand Up @@ -610,7 +610,7 @@ def test_run_query_w_eventual_and_transaction(self):
rsp_pb.batch.more_results = no_more
rsp_pb.batch.entity_result_type = datastore_pb.EntityResult.FULL
conn = self._makeOne()
conn.transaction(TRANSACTION)
conn.transaction(Transaction(TRANSACTION))
self.assertRaises(
ValueError, conn.run_query, DATASET_ID, q_pb, eventual=True)

Expand Down Expand Up @@ -1174,3 +1174,12 @@ def request(self, **kw):
self._called_with.append(kw)
result, self._responses = self._responses[0], self._responses[1:]
return result


class Transaction(object):

This comment was marked as spam.


def __init__(self, id):
self._id = id

def id(self):
return self._id