From 538084d4066f4a17a2ae59aeec1550837710e331 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 17 Oct 2014 12:35:41 -0400 Subject: [PATCH] Drop munging of 's~' prefix onto keys. Fixes #121. Note: may conflict with PR #257 and #258. --- gcloud/datastore/key.py | 5 ----- gcloud/datastore/test_connection.py | 18 +++++++++--------- gcloud/datastore/test_key.py | 18 +----------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/gcloud/datastore/key.py b/gcloud/datastore/key.py index 9950b1cd9b755..33913cbd42062 100644 --- a/gcloud/datastore/key.py +++ b/gcloud/datastore/key.py @@ -95,13 +95,8 @@ def to_protobuf(self): # but we shouldn't throw a cryptic error if one isn't provided # in the initializer. if self.dataset(): - # Apparently 's~' is a prefix for High-Replication and is necessary - # here. Another valid preflix is 'e~' indicating EU datacenters. dataset_id = self.dataset().id() if dataset_id: - if dataset_id[:2] not in ['s~', 'e~']: - dataset_id = 's~' + dataset_id - key.partition_id.dataset_id = dataset_id if self._namespace: diff --git a/gcloud/datastore/test_connection.py b/gcloud/datastore/test_connection.py index 8471e4cb1c81a..cf7f08276b2d6 100644 --- a/gcloud/datastore/test_connection.py +++ b/gcloud/datastore/test_connection.py @@ -406,7 +406,7 @@ def test_lookup_single_key_empty_response(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '26', + 'Content-Length': '24', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.LookupRequest @@ -445,7 +445,7 @@ def test_lookup_single_key_nonempty_response(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '26', + 'Content-Length': '24', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.LookupRequest @@ -481,7 +481,7 @@ def test_lookup_multiple_keys_empty_response(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '52', + 'Content-Length': '48', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.LookupRequest @@ -524,7 +524,7 @@ def test_commit_wo_transaction(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '47', + 'Content-Length': '45', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest @@ -570,7 +570,7 @@ def id(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '53', + 'Content-Length': '51', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest @@ -605,7 +605,7 @@ def test_save_entity_wo_transaction_w_upsert(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '47', + 'Content-Length': '45', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest @@ -656,7 +656,7 @@ def test_save_entity_wo_transaction_w_auto_id(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '44', + 'Content-Length': '42', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest @@ -751,7 +751,7 @@ def test_delete_entities_wo_transaction(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '30', + 'Content-Length': '28', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest @@ -816,7 +816,7 @@ def test_delete_entity_wo_transaction(self): self.assertEqual(cw['method'], 'POST') self.assertEqual(cw['headers'], {'Content-Type': 'application/x-protobuf', - 'Content-Length': '30', + 'Content-Length': '28', 'User-Agent': conn.USER_AGENT, }) rq_class = datastore_pb.CommitRequest diff --git a/gcloud/datastore/test_key.py b/gcloud/datastore/test_key.py index 5fca22f24358f..a21ca0cd67aa9 100644 --- a/gcloud/datastore/test_key.py +++ b/gcloud/datastore/test_key.py @@ -133,28 +133,12 @@ def test_to_protobuf_w_explicit_dataset_empty_id(self): pb = key.to_protobuf() self.assertEqual(pb.partition_id.dataset_id, '') - def test_to_protobuf_w_explicit_dataset_no_prefix(self): + def test_to_protobuf_w_explicit_dataset(self): from gcloud.datastore.dataset import Dataset _DATASET = 'DATASET' dataset = Dataset(_DATASET) key = self._makeOne(dataset) pb = key.to_protobuf() - self.assertEqual(pb.partition_id.dataset_id, 's~%s' % _DATASET) - - def test_to_protobuf_w_explicit_dataset_w_s_prefix(self): - from gcloud.datastore.dataset import Dataset - _DATASET = 's~DATASET' - dataset = Dataset(_DATASET) - key = self._makeOne(dataset) - pb = key.to_protobuf() - self.assertEqual(pb.partition_id.dataset_id, _DATASET) - - def test_to_protobuf_w_explicit_dataset_w_e_prefix(self): - from gcloud.datastore.dataset import Dataset - _DATASET = 'e~DATASET' - dataset = Dataset(_DATASET) - key = self._makeOne(dataset) - pb = key.to_protobuf() self.assertEqual(pb.partition_id.dataset_id, _DATASET) def test_to_protobuf_w_explicit_namespace(self):