@@ -917,6 +917,42 @@ def test_allocate_ids_non_empty(self):
917917 request .ParseFromString (cw ['body' ])
918918 self .assertEqual (list (request .key ), before_key_pbs )
919919
920+ def test_save_entity_w_empty_list (self ):
921+ from gcloud .datastore .connection import datastore_pb
922+ from gcloud .datastore .key import Key
923+
924+ DATASET_ID = 'DATASET'
925+ key_pb = Key (path = [{'kind' : 'Kind' , 'id' : 1234 }]).to_protobuf ()
926+ rsp_pb = datastore_pb .CommitResponse ()
927+ conn = self ._makeOne ()
928+ URI = '/' .join ([
929+ conn .API_BASE_URL ,
930+ 'datastore' ,
931+ conn .API_VERSION ,
932+ 'datasets' ,
933+ DATASET_ID ,
934+ 'commit' ,
935+ ])
936+ http = conn ._http = Http ({'status' : '200' }, rsp_pb .SerializeToString ())
937+ result = conn .save_entity (DATASET_ID , key_pb ,
938+ {'foo' : u'Foo' , 'bar' : []})
939+ self .assertEqual (result , True )
940+ cw = http ._called_with
941+ self ._verifyProtobufCall (cw , URI , conn )
942+ rq_class = datastore_pb .CommitRequest
943+ request = rq_class ()
944+ request .ParseFromString (cw ['body' ])
945+ self .assertEqual (request .transaction , '' )
946+ mutation = request .mutation
947+ self .assertEqual (len (mutation .insert_auto_id ), 0 )
948+ upserts = list (mutation .upsert )
949+ self .assertEqual (len (upserts ), 1 )
950+ upsert = upserts [0 ]
951+ self .assertEqual (upsert .key , key_pb )
952+ props = list (upsert .property )
953+ self .assertEqual (len (props ), 1 )
954+ self .assertNotEqual (props [0 ].name , 'bar' )
955+
920956 def test_save_entity_wo_transaction_w_upsert (self ):
921957 from gcloud .datastore .connection import datastore_pb
922958 from gcloud .datastore .key import Key
0 commit comments