Skip to content

Commit

Permalink
Renaming namespace->namespace_id on PartitionId.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed Jan 21, 2016
1 parent 7ac8e46 commit 3ae3b07
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def run_query(self, project, query_pb, namespace=None,
_set_read_options(request, eventual, transaction_id)

if namespace:
request.partition_id.namespace = namespace
request.partition_id.namespace_id = namespace

request.query.CopyFrom(query_pb)
response = self._rpc(project, 'runQuery', request,
Expand Down
4 changes: 2 additions & 2 deletions gcloud/datastore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def key_from_protobuf(pb):
if _has_field(pb.partition_id, 'project_id'):
project = pb.partition_id.project_id
namespace = None
if _has_field(pb.partition_id, 'namespace'):
namespace = pb.partition_id.namespace
if _has_field(pb.partition_id, 'namespace_id'):
namespace = pb.partition_id.namespace_id

return Key(*path_args, namespace=namespace, project=project)

Expand Down
2 changes: 1 addition & 1 deletion gcloud/datastore/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def to_protobuf(self):
key.partition_id.project_id = self.project

if self.namespace:
key.partition_id.namespace = self.namespace
key.partition_id.namespace_id = self.namespace

for item in self.path:
element = key.path_element.add()
Expand Down
12 changes: 6 additions & 6 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def test_run_query_w_eventual_no_transaction(self):
rq_class = datastore_pb2.RunQueryRequest
request = rq_class()
request.ParseFromString(cw['body'])
self.assertEqual(request.partition_id.namespace, '')
self.assertEqual(request.partition_id.namespace_id, '')
self.assertEqual(request.query, q_pb)
self.assertEqual(request.read_options.read_consistency,
datastore_pb2.ReadOptions.EVENTUAL)
Expand Down Expand Up @@ -549,7 +549,7 @@ def test_run_query_wo_eventual_w_transaction(self):
rq_class = datastore_pb2.RunQueryRequest
request = rq_class()
request.ParseFromString(cw['body'])
self.assertEqual(request.partition_id.namespace, '')
self.assertEqual(request.partition_id.namespace_id, '')
self.assertEqual(request.query, q_pb)
self.assertEqual(request.read_options.read_consistency,
datastore_pb2.ReadOptions.DEFAULT)
Expand Down Expand Up @@ -606,7 +606,7 @@ def test_run_query_wo_namespace_empty_result(self):
rq_class = datastore_pb2.RunQueryRequest
request = rq_class()
request.ParseFromString(cw['body'])
self.assertEqual(request.partition_id.namespace, '')
self.assertEqual(request.partition_id.namespace_id, '')
self.assertEqual(request.query, q_pb)

def test_run_query_w_namespace_nonempty_result(self):
Expand Down Expand Up @@ -638,7 +638,7 @@ def test_run_query_w_namespace_nonempty_result(self):
rq_class = datastore_pb2.RunQueryRequest
request = rq_class()
request.ParseFromString(cw['body'])
self.assertEqual(request.partition_id.namespace, 'NS')
self.assertEqual(request.partition_id.namespace_id, 'NS')
self.assertEqual(request.query, q_pb)

def test_begin_transaction(self):
Expand Down Expand Up @@ -902,8 +902,8 @@ def request(self, **kw):
def _compare_key_pb_after_request(test, key_before, key_after):
from gcloud._helpers import _has_field
test.assertFalse(_has_field(key_after.partition_id, 'project_id'))
test.assertEqual(key_before.partition_id.namespace,
key_after.partition_id.namespace)
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):
Expand Down
2 changes: 1 addition & 1 deletion gcloud/datastore/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def _makePB(self, project=None, namespace=None, path=()):
if project is not None:
pb.partition_id.project_id = project
if namespace is not None:
pb.partition_id.namespace = namespace
pb.partition_id.namespace_id = namespace
for elem in path:
added = pb.path_element.add()
added.kind = elem['kind']
Expand Down
6 changes: 3 additions & 3 deletions gcloud/datastore/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def test_to_protobuf_defaults(self):

# Check partition ID.
self.assertEqual(pb.partition_id.project_id, self._DEFAULT_PROJECT)
self.assertEqual(pb.partition_id.namespace, '')
self.assertFalse(_has_field(pb.partition_id, 'namespace'))
self.assertEqual(pb.partition_id.namespace_id, '')
self.assertFalse(_has_field(pb.partition_id, 'namespace_id'))

# Check the element PB matches the partial key and kind.
elem, = list(pb.path_element)
Expand All @@ -365,7 +365,7 @@ def test_to_protobuf_w_explicit_namespace(self):
key = self._makeOne('KIND', namespace=_NAMESPACE,
project=self._DEFAULT_PROJECT)
pb = key.to_protobuf()
self.assertEqual(pb.partition_id.namespace, _NAMESPACE)
self.assertEqual(pb.partition_id.namespace_id, _NAMESPACE)

def test_to_protobuf_w_explicit_path(self):
_PARENT = 'PARENT'
Expand Down

0 comments on commit 3ae3b07

Please sign in to comment.