diff --git a/gcloud/datastore/batch.py b/gcloud/datastore/batch.py index ff6048aebf00..de2cb021b39d 100644 --- a/gcloud/datastore/batch.py +++ b/gcloud/datastore/batch.py @@ -242,7 +242,7 @@ def _commit(self): # order) directly ``_partial_key_entities``. for new_key_pb, entity in zip(updated_keys, self._partial_key_entities): - new_id = new_key_pb.path_element[-1].id + new_id = new_key_pb.path[-1].id entity.key = entity.key.completed_key(new_id) def commit(self): diff --git a/gcloud/datastore/client.py b/gcloud/datastore/client.py index 22900d6d557e..1d97f5c494ff 100644 --- a/gcloud/datastore/client.py +++ b/gcloud/datastore/client.py @@ -416,7 +416,7 @@ def allocate_ids(self, incomplete_key, num_ids): conn = self.connection allocated_key_pbs = conn.allocate_ids(incomplete_key.project, incomplete_key_pbs) - allocated_ids = [allocated_key_pb.path_element[-1].id + allocated_ids = [allocated_key_pb.path[-1].id for allocated_key_pb in allocated_key_pbs] return [incomplete_key.completed_key(allocated_id) for allocated_id in allocated_ids] diff --git a/gcloud/datastore/helpers.py b/gcloud/datastore/helpers.py index df505c59be64..71350d804849 100644 --- a/gcloud/datastore/helpers.py +++ b/gcloud/datastore/helpers.py @@ -258,7 +258,7 @@ def key_from_protobuf(pb): :returns: a new `Key` instance """ path_args = [] - for element in pb.path_element: + for element in pb.path: path_args.append(element.kind) if element.id: # Simple field (int64) path_args.append(element.id) diff --git a/gcloud/datastore/key.py b/gcloud/datastore/key.py index 935f2ffa9935..90315d0f3105 100644 --- a/gcloud/datastore/key.py +++ b/gcloud/datastore/key.py @@ -246,7 +246,7 @@ def to_protobuf(self): key.partition_id.namespace_id = self.namespace for item in self.path: - element = key.path_element.add() + element = key.path.add() if 'kind' in item: element.kind = item['kind'] if 'id' in item: diff --git a/gcloud/datastore/test_batch.py b/gcloud/datastore/test_batch.py index c79844dfa6e5..a8d96370cce9 100644 --- a/gcloud/datastore/test_batch.py +++ b/gcloud/datastore/test_batch.py @@ -346,7 +346,7 @@ def __init__(self, id): class _KeyPB(object): def __init__(self, id): - self.path_element = [_PathElementPB(id)] + self.path = [_PathElementPB(id)] class _Connection(object): @@ -390,7 +390,7 @@ def to_protobuf(self): # Don't assign it, because it will just get ripped out # key.partition_id.project_id = self.project - element = key.path_element.add() + element = key.path.add() element.kind = self._kind if self._id is not None: element.id = self._id diff --git a/gcloud/datastore/test_client.py b/gcloud/datastore/test_client.py index 1bcd2e3a3d58..9908816e3644 100644 --- a/gcloud/datastore/test_client.py +++ b/gcloud/datastore/test_client.py @@ -21,7 +21,7 @@ def _make_entity_pb(project, kind, integer_id, name=None, str_val=None): entity_pb = entity_pb2.Entity() entity_pb.key.partition_id.project_id = project - path_element = entity_pb.key.path_element.add() + path_element = entity_pb.key.path.add() path_element.kind = kind path_element.id = integer_id if name is not None and str_val is not None: @@ -323,7 +323,7 @@ def test_get_multi_miss_w_missing(self): # Make a missing entity pb to be returned from mock backend. missed = entity_pb2.Entity() missed.key.partition_id.project_id = self.PROJECT - path_element = missed.key.path_element.add() + path_element = missed.key.path.add() path_element.kind = KIND path_element.id = ID diff --git a/gcloud/datastore/test_connection.py b/gcloud/datastore/test_connection.py index 4394f3b95dd5..d484910a087b 100644 --- a/gcloud/datastore/test_connection.py +++ b/gcloud/datastore/test_connection.py @@ -341,8 +341,8 @@ def test_lookup_single_key_nonempty_response(self): (found,), missing, deferred = conn.lookup(PROJECT, [key_pb]) self.assertEqual(len(missing), 0) self.assertEqual(len(deferred), 0) - self.assertEqual(found.key.path_element[0].kind, 'Kind') - self.assertEqual(found.key.path_element[0].id, 1234) + self.assertEqual(found.key.path[0].kind, 'Kind') + self.assertEqual(found.key.path[0].id, 1234) cw = http._called_with self._verifyProtobufCall(cw, URI, conn) rq_class = datastore_pb2.LookupRequest @@ -816,7 +816,7 @@ def test_it(self): index_updates = 1337 keys = [ entity_pb2.Key( - path_element=[ + path=[ entity_pb2.Key.PathElement( kind='Foo', id=1234, @@ -824,7 +824,7 @@ def test_it(self): ], ), entity_pb2.Key( - path_element=[ + path=[ entity_pb2.Key.PathElement( kind='Bar', name='baz', @@ -861,9 +861,9 @@ def _compare_key_pb_after_request(test, key_before, key_after): test.assertEqual(key_after.partition_id.project_id, '') test.assertEqual(key_before.partition_id.namespace_id, key_after.partition_id.namespace_id) - test.assertEqual(len(key_before.path_element), - len(key_after.path_element)) - for elt1, elt2 in zip(key_before.path_element, key_after.path_element): + test.assertEqual(len(key_before.path), + len(key_after.path)) + for elt1, elt2 in zip(key_before.path, key_after.path): test.assertEqual(elt1, elt2) @@ -876,4 +876,4 @@ def __init__(self, _id): class _KeyProto(object): def __init__(self, id_): - self.path_element = [_PathElementProto(id_)] + self.path = [_PathElementProto(id_)] diff --git a/gcloud/datastore/test_helpers.py b/gcloud/datastore/test_helpers.py index d4a1d62e6813..76fbe6fd15ad 100644 --- a/gcloud/datastore/test_helpers.py +++ b/gcloud/datastore/test_helpers.py @@ -71,7 +71,7 @@ def test_it(self): _ID = 1234 entity_pb = entity_pb2.Entity() entity_pb.key.partition_id.project_id = _PROJECT - entity_pb.key.path_element.add(kind=_KIND, id=_ID) + entity_pb.key.path.add(kind=_KIND, id=_ID) value_pb = _new_value_pb(entity_pb, 'foo') value_pb.string_value = 'Foo' @@ -117,7 +117,7 @@ def test_mismatched_value_indexed(self): _ID = 1234 entity_pb = entity_pb2.Entity() entity_pb.key.partition_id.project_id = _PROJECT - entity_pb.key.path_element.add(kind=_KIND, id=_ID) + entity_pb.key.path.add(kind=_KIND, id=_ID) list_val_pb = _new_value_pb(entity_pb, 'baz') list_pb = list_val_pb.list_value @@ -172,7 +172,7 @@ def test_nested_entity_no_key(self): entity_pb = entity_pb2.Entity() entity_pb.key.partition_id.project_id = PROJECT - element = entity_pb.key.path_element.add() + element = entity_pb.key.path.add() element.kind = KIND outside_val_pb = _new_value_pb(entity_pb, OUTSIDE_NAME) @@ -234,7 +234,7 @@ def test_key_only(self): expected_pb = entity_pb2.Entity() expected_pb.key.partition_id.project_id = project - path_elt = expected_pb.key.path_element.add() + path_elt = expected_pb.key.path.add() path_elt.kind = kind path_elt.name = name @@ -278,10 +278,10 @@ def test_inverts_to_protobuf(self): original_pb = entity_pb2.Entity() # Add a key. original_pb.key.partition_id.project_id = project = 'PROJECT' - elem1 = original_pb.key.path_element.add() + elem1 = original_pb.key.path.add() elem1.kind = 'Family' elem1.id = 1234 - elem2 = original_pb.key.path_element.add() + elem2 = original_pb.key.path.add() elem2.kind = 'King' elem2.name = 'Spades' @@ -357,7 +357,7 @@ def _makePB(self, project=None, namespace=None, path=()): if namespace is not None: pb.partition_id.namespace_id = namespace for elem in path: - added = pb.path_element.add() + added = pb.path.add() added.kind = elem['kind'] if 'id' in elem: added.id = elem['id'] @@ -560,7 +560,7 @@ def test_entity(self): pb = entity_pb2.Value() entity_pb = pb.entity_value - entity_pb.key.path_element.add(kind='KIND') + entity_pb.key.path.add(kind='KIND') entity_pb.key.partition_id.project_id = 'PROJECT' value_pb = _new_value_pb(entity_pb, 'foo') @@ -776,7 +776,7 @@ def test_unprefixed_bogus_key_miss(self): # Make sure just one. called_key_pb, = CONNECTION._called_key_pbs - path_element = called_key_pb.path_element + path_element = called_key_pb.path self.assertEqual(len(path_element), 1) self.assertEqual(path_element[0].kind, '__MissingLookupKind') self.assertEqual(path_element[0].id, 1) @@ -797,7 +797,7 @@ def test_unprefixed_bogus_key_hit(self): # Make sure just one. called_key_pb, = CONNECTION._called_key_pbs - path_element = called_key_pb.path_element + path_element = called_key_pb.path self.assertEqual(len(path_element), 1) self.assertEqual(path_element[0].kind, '__MissingLookupKind') self.assertEqual(path_element[0].id, 1) diff --git a/gcloud/datastore/test_key.py b/gcloud/datastore/test_key.py index ea68c5bc3913..3aaf79549063 100644 --- a/gcloud/datastore/test_key.py +++ b/gcloud/datastore/test_key.py @@ -346,7 +346,7 @@ def test_to_protobuf_defaults(self): self.assertEqual(pb.partition_id.namespace_id, '') # Check the element PB matches the partial key and kind. - elem, = list(pb.path_element) + elem, = list(pb.path) self.assertEqual(elem.kind, _KIND) # Unset values are False-y. self.assertEqual(elem.name, '') @@ -374,7 +374,7 @@ def test_to_protobuf_w_explicit_path(self): key = self._makeOne(_PARENT, _NAME, _CHILD, _ID, project=self._DEFAULT_PROJECT) pb = key.to_protobuf() - elems = list(pb.path_element) + elems = list(pb.path) self.assertEqual(len(elems), 2) self.assertEqual(elems[0].kind, _PARENT) self.assertEqual(elems[0].name, _NAME) @@ -388,7 +388,7 @@ def test_to_protobuf_w_no_kind(self): key._path[-1].pop('kind') pb = key.to_protobuf() # Unset values are False-y. - self.assertEqual(pb.path_element[0].kind, '') + self.assertEqual(pb.path[0].kind, '') def test_is_partial_no_name_or_id(self): key = self._makeOne('KIND', project=self._DEFAULT_PROJECT) diff --git a/gcloud/datastore/test_query.py b/gcloud/datastore/test_query.py index 018cc70fdcfe..114529df90cb 100644 --- a/gcloud/datastore/test_query.py +++ b/gcloud/datastore/test_query.py @@ -355,7 +355,7 @@ def _addQueryResults(self, connection, cursor=_END, more=False): _ID = 123 entity_pb = entity_pb2.Entity() entity_pb.key.partition_id.project_id = self._PROJECT - path_element = entity_pb.key.path_element.add() + path_element = entity_pb.key.path.add() path_element.kind = self._KIND path_element.id = _ID value_pb = _new_value_pb(entity_pb, 'foo') diff --git a/gcloud/datastore/test_transaction.py b/gcloud/datastore/test_transaction.py index e98f2faca17f..d7fb9bc9096b 100644 --- a/gcloud/datastore/test_transaction.py +++ b/gcloud/datastore/test_transaction.py @@ -167,7 +167,7 @@ def _make_key(kind, id_, project): key = entity_pb2.Key() key.partition_id.project_id = project - elem = key.path_element.add() + elem = key.path.add() elem.kind = kind elem.id = id_ return key