Skip to content

Commit 3d14518

Browse files
committed
Fix regression test failure introduced in PR #449.
1 parent 40428f2 commit 3d14518

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

gcloud/datastore/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def _set_read_options(self, request, eventual):
559559
if eventual:
560560
opts.read_consistency = datastore_pb.ReadOptions.EVENTUAL
561561
elif transaction:
562-
opts.transaction = transaction
562+
opts.transaction = transaction.id()
563563

564564

565565
def _copy_deferred_keys(lookup_request, lookup_response):

gcloud/datastore/test_connection.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_lookup_single_key_empty_response_w_eventual_and_transaction(self):
268268
TRANSACTION = 'TRANSACTION'
269269
key_pb = Key(path=[{'kind': 'Kind', 'id': 1234}]).to_protobuf()
270270
conn = self._makeOne()
271-
conn.transaction(TRANSACTION)
271+
conn.transaction(Transaction(TRANSACTION))
272272
self.assertRaises(
273273
ValueError, conn.lookup, DATASET_ID, key_pb, eventual=True)
274274

@@ -281,7 +281,7 @@ def test_lookup_single_key_empty_response_w_transaction(self):
281281
key_pb = Key(path=[{'kind': 'Kind', 'id': 1234}]).to_protobuf()
282282
rsp_pb = datastore_pb.LookupResponse()
283283
conn = self._makeOne()
284-
conn.transaction(TRANSACTION)
284+
conn.transaction(Transaction(TRANSACTION))
285285
URI = '/'.join([
286286
conn.API_BASE_URL,
287287
'datastore',
@@ -569,7 +569,7 @@ def test_run_query_wo_eventual_w_transaction(self):
569569
rsp_pb.batch.more_results = no_more
570570
rsp_pb.batch.entity_result_type = datastore_pb.EntityResult.FULL
571571
conn = self._makeOne()
572-
conn.transaction(TRANSACTION)
572+
conn.transaction(Transaction(TRANSACTION))
573573
URI = '/'.join([
574574
conn.API_BASE_URL,
575575
'datastore',
@@ -610,7 +610,7 @@ def test_run_query_w_eventual_and_transaction(self):
610610
rsp_pb.batch.more_results = no_more
611611
rsp_pb.batch.entity_result_type = datastore_pb.EntityResult.FULL
612612
conn = self._makeOne()
613-
conn.transaction(TRANSACTION)
613+
conn.transaction(Transaction(TRANSACTION))
614614
self.assertRaises(
615615
ValueError, conn.run_query, DATASET_ID, q_pb, eventual=True)
616616

@@ -1174,3 +1174,12 @@ def request(self, **kw):
11741174
self._called_with.append(kw)
11751175
result, self._responses = self._responses[0], self._responses[1:]
11761176
return result
1177+
1178+
1179+
class Transaction(object):
1180+
1181+
def __init__(self, id):
1182+
self._id = id
1183+
1184+
def id(self):
1185+
return self._id

0 commit comments

Comments
 (0)