Created
December 4, 2014 15:01
-
-
Save bryanyang0528/ec4ab627da5fa4434056 to your computer and use it in GitHub Desktop.
unitest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_get_entity_path(self): | |
from gcloud.datastore.connection import datastore_pb | |
DATASET_ID = 'DATASET' | |
KIND = 'Kind' | |
ID = 1234 | |
PATH = [{'kind': KIND, 'id': ID}] | |
entity_pb = datastore_pb.Entity() | |
entity_pb.key.partition_id.dataset_id = DATASET_ID | |
path_element = entity_pb.key.path_element.add() | |
path_element.kind = KIND | |
path_element.id = ID | |
prop = entity_pb.property.add() | |
prop.name = 'foo' | |
prop.value.string_value = 'Foo' | |
connection = _Connection(entity_pb) | |
dataset = self._makeOne(DATASET_ID, connection) | |
result = dataset.get_entity([KIND, ID]) | |
key = result.key() | |
self.assertEqual(key._dataset_id, DATASET_ID) | |
self.assertEqual(key.path(), PATH) | |
self.assertEqual(list(result), ['foo']) | |
self.assertEqual(result['foo'], 'Foo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment