Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gcloud/datastore/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from gcloud.datastore import _implicit_environ
from gcloud.datastore.batch import Batch
from gcloud.datastore.entity import Entity
from gcloud.datastore.transaction import Transaction
from gcloud.datastore import helpers

Expand Down Expand Up @@ -252,6 +253,9 @@ def put(entities, connection=None, dataset_id=None):
one or more entities has a key with a dataset ID not matching
the passed / inferred dataset ID.
"""
if isinstance(entities, Entity):
raise ValueError("Pass a sequence of entities")

if not entities:
return

Expand Down
5 changes: 5 additions & 0 deletions gcloud/datastore/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ def test_no_entities(self):
result = self._callFUT([])
self.assertEqual(result, None)

def test_w_single_empty_entity(self):
# https://github.com/GoogleCloudPlatform/gcloud-python/issues/649
from gcloud.datastore.entity import Entity
self.assertRaises(ValueError, self._callFUT, Entity())

def test_no_batch_w_partial_key(self):
from gcloud.datastore.test_batch import _Connection
from gcloud.datastore.test_batch import _Entity
Expand Down