def test_from_key_wo_dataset(self): from gcloud.datastore.key import Key klass = self._getTargetClass() key = Key().kind(_KIND).id(_ID) entity = klass.from_key(key) self.assertTrue(entity.dataset() is None) self.assertEqual(entity.kind(), _KIND) key = entity.key() self.assertEqual(key.kind(), _KIND) self.assertEqual(key.id(), _ID)
def test_from_key(self): from gcloud.datastore.dataset import Dataset from gcloud.datastore.key import Key klass = self._getTargetClass() dataset = Dataset(_DATASET_ID) key = Key(dataset=dataset).kind(_KIND).id(_ID) entity = klass.from_key(key) self.assertTrue(entity.dataset() is dataset) self.assertEqual(entity.kind(), _KIND) key = entity.key() self.assertEqual(key.kind(), _KIND) self.assertEqual(key.id(), _ID)
def test_from_key_w_dataset(self): from gcloud.datastore.dataset import Dataset from gcloud.datastore.key import Key klass = self._getTargetClass() dataset = Dataset(_DATASET_ID) key = Key().kind(_KIND).id(_ID) entity = klass.from_key(key, dataset) self.assertTrue(entity.dataset() is dataset) self.assertEqual(entity.kind(), _KIND) key = entity.key() self.assertEqual(key.kind(), _KIND) self.assertEqual(key.id(), _ID)