Exemplo n.º 1
0
 def from_client_entity(client_entity):
     key = Key.from_client_key(client_entity.key)
     entity = Entity(key,
                     exclude_from_indexes=set(
                         client_entity.exclude_from_indexes))
     entity.set_properties(client_entity)
     return entity
Exemplo n.º 2
0
  def test_DatastoreWriteLargeEntities(self):
    """100*100kB entities gets split over two Commit RPCs."""
    with patch.object(helper, 'get_client', return_value=self._mock_client):
      entities = helper.create_entities(100)
      commit_count = [0]
      self._mock_client.batch.side_effect = (
          lambda: FakeBatch(commit_count=commit_count))

      datastore_write_fn = WriteToDatastore._DatastoreWriteFn(self._PROJECT)
      datastore_write_fn.start_bundle()
      for entity in entities:
        entity.set_properties({'large': u'A' * 100000})
        datastore_write_fn.process(entity)
      datastore_write_fn.finish_bundle()

      self.assertEqual(2, commit_count[0])