Skip to content

Commit

Permalink
Return True from 'Connection.delete_entities' unconditionally.
Browse files Browse the repository at this point in the history
Fixes #168.

Merges 169-connection_delete_entity, too.
  • Loading branch information
tseaver committed Oct 17, 2014
1 parent 94e606b commit 8ebace3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 5 additions & 6 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,16 +398,15 @@ def delete_entities(self, dataset_id, key_pbs):
:rtype: boolean (if in a transaction) or else
:class:`gcloud.datastore.datastore_v1_pb2.MutationResult`.
:returns: True (if in a transaction) or else a mutation result
protobuf.
:returns: True
"""
mutation = self.mutation()

for key_pb in key_pbs:
delete = mutation.delete.add()
delete.CopyFrom(key_pb)

if self.transaction():
return True
else:
return self.commit(dataset_id, mutation)
if not self.transaction():
self.commit(dataset_id, mutation)

return True
3 changes: 1 addition & 2 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,7 @@ def test_delete_entities_wo_transaction(self):
'commit', ])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result = conn.delete_entities(DATASET_ID, [key_pb])
self.assertEqual(result.index_updates, 0)
self.assertEqual(list(result.insert_auto_id_key), [])
self.assertEqual(result, True)
cw = http._called_with
self.assertEqual(cw['uri'], URI)
self.assertEqual(cw['method'], 'POST')
Expand Down

0 comments on commit 8ebace3

Please sign in to comment.