Skip to content

Commit

Permalink
Merge pull request googleapis#452 from tseaver/449-fix_transaction_bo…
Browse files Browse the repository at this point in the history
…rked_in_449

Fix regression test failure introduced in PR googleapis#449.
  • Loading branch information
tseaver committed Dec 19, 2014
2 parents 40428f2 + 3d14518 commit b343acf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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):

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

def id(self):
return self._id

0 comments on commit b343acf

Please sign in to comment.