当前位置: 首页>>代码示例>>Python>>正文


Python apiproxy_stub_map.APIProxyStubMap方法代码示例

本文整理汇总了Python中google.appengine.api.apiproxy_stub_map.APIProxyStubMap方法的典型用法代码示例。如果您正苦于以下问题:Python apiproxy_stub_map.APIProxyStubMap方法的具体用法?Python apiproxy_stub_map.APIProxyStubMap怎么用?Python apiproxy_stub_map.APIProxyStubMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.api.apiproxy_stub_map的用法示例。


在下文中一共展示了apiproxy_stub_map.APIProxyStubMap方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _convert_datastore_file_stub_data_to_sqlite

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def _convert_datastore_file_stub_data_to_sqlite(app_id, datastore_path):
  logging.info('Converting datastore stub data to sqlite.')
  previous_stub = apiproxy_stub_map.apiproxy.GetStub('datastore_v3')
  try:
    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    datastore_stub = datastore_file_stub.DatastoreFileStub(
        app_id, datastore_path, trusted=True, save_changes=False)
    apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore_stub)

    entities = _fetch_all_datastore_entities()
    sqlite_datastore_stub = datastore_sqlite_stub.DatastoreSqliteStub(
        app_id, datastore_path + '.sqlite', trusted=True)
    apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3',
                                           sqlite_datastore_stub)
    datastore.Put(entities)
    sqlite_datastore_stub.Close()
  finally:
    apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', previous_stub)

  shutil.copy(datastore_path, datastore_path + '.filestub')
  os.remove(datastore_path)
  shutil.move(datastore_path + '.sqlite', datastore_path)
  logging.info('Datastore conversion complete. File stub data has been backed '
               'up in %s', datastore_path + '.filestub') 
开发者ID:elsigh,项目名称:browserscope,代码行数:26,代码来源:api_server.py

示例2: activate

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def activate(self):
    """Activates the testbed.

    Invoking this method will also assign default values to environment
    variables that are required by App Engine services, such as
    `os.environ['APPLICATION_ID']`. You can set custom values with
    `setup_env()`.
    """
    self._orig_env = dict(os.environ)
    self.setup_env()






    self._original_stub_map = apiproxy_stub_map.apiproxy
    self._test_stub_map = apiproxy_stub_map.APIProxyStubMap()
    internal_map = self._original_stub_map._APIProxyStubMap__stub_map
    self._test_stub_map._APIProxyStubMap__stub_map = dict(internal_map)
    apiproxy_stub_map.apiproxy = self._test_stub_map
    self._activated = True 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:24,代码来源:__init__.py

示例3: setUp

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setUp(self):
    unittest.TestCase.setUp(self)
    self.app_id = "myapp"

    self.mapper_spec = model.MapperSpec.from_json({
        "mapper_handler_spec": "FooHandler",
        "mapper_input_reader": NamespaceInputReaderTest.MAPREDUCE_READER_SPEC,
        "mapper_params": {"batch_size": 2},
        "mapper_shard_count": 10})

    os.environ["APPLICATION_ID"] = self.app_id

    self.datastore = datastore_file_stub.DatastoreFileStub(
        self.app_id, "/dev/null", "/dev/null")

    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    apiproxy_stub_map.apiproxy.RegisterStub("datastore_v3", self.datastore) 
开发者ID:GoogleCloudPlatform,项目名称:appengine-mapreduce,代码行数:19,代码来源:input_readers_test.py

示例4: _run_test_suite

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def _run_test_suite(runner, suite):
    """Run the test suite.

    Preserve the current development apiproxy, create a new apiproxy and
    replace the datastore with a temporary one that will be used for this
    test suite, run the test suite, and restore the development apiproxy.
    This isolates the test datastore from the development datastore.

    """
    original_apiproxy = apiproxy_stub_map.apiproxy
    try:
       apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
       apiproxy_stub_map.apiproxy.RegisterStub(
           'datastore',
           datastore_file_stub.DatastoreFileStub(
               'GAEUnitDataStore', datastore_file=None, trusted=True))
       apiproxy_stub_map.apiproxy.RegisterStub(
           'memcache',
           memcache_stub.MemcacheServiceStub())
       apiproxy_stub_map.apiproxy.RegisterStub(
           'taskqueue',
           TestingTaskQueueService(root_path='.'))
       # Allow the other services to be used as-is for tests.
       for name in ('user', 'urlfetch', 'mail', 'images'):
           apiproxy_stub_map.apiproxy.RegisterStub(
               name, original_apiproxy.GetStub(name))
       # TODO(slamm): add coverage tool here.
       runner.run(suite)
    finally:
       apiproxy_stub_map.apiproxy = original_apiproxy 
开发者ID:elsigh,项目名称:browserscope,代码行数:32,代码来源:gaeunit.py

示例5: setUp

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setUp(self):
    """Configure test harness."""
    # Configure os.environ to make it look like the relevant parts of the
    # CGI environment that the stub relies on.
    self.original_environ = dict(os.environ)
    os.environ.update({
        'APPLICATION_ID': 'app',
        'SERVER_NAME': 'localhost',
        'SERVER_PORT': '8080',
        'AUTH_DOMAIN': 'abcxyz.com',
        'USER_EMAIL': 'user@abcxyz.com',
        })

    # Set up mox.
    self.mox = mox.Mox()

    # Use a fresh file datastore stub.
    self.tmpdir = tempfile.mkdtemp()
    self.datastore_file = os.path.join(self.tmpdir, 'datastore_v3')
    self.history_file = os.path.join(self.tmpdir, 'history')
    for filename in [self.datastore_file, self.history_file]:
      if os.access(filename, os.F_OK):
        os.remove(filename)

    self.stub = datastore_file_stub.DatastoreFileStub(
        'app', self.datastore_file, self.history_file, use_atexit=False)

    self.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    apiproxy_stub_map.apiproxy = self.apiproxy
    apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', self.stub) 
开发者ID:elsigh,项目名称:browserscope,代码行数:32,代码来源:blob_upload_test.py

示例6: setUp

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setUp(self):
    """Configure test harness."""
    # Configure os.environ to make it look like the relevant parts of the
    # CGI environment that the stub relies on.
    self.original_environ = dict(os.environ)
    os.environ.update({
        'APPLICATION_ID': 'app',
        'SERVER_NAME': 'localhost',
        'SERVER_PORT': '8080',
        'AUTH_DOMAIN': 'abcxyz.com',
        'USER_EMAIL': 'user@abcxyz.com',
        })

    # Set up testing blobstore files.
    self.tmpdir = tempfile.mkdtemp()
    storage_directory = os.path.join(self.tmpdir, 'blob_storage')
    self.blob_storage = file_blob_storage.FileBlobStorage(storage_directory,
                                                          'appid1')
    self.blobstore_stub = blobstore_stub.BlobstoreServiceStub(self.blob_storage)

    # Use a fresh file datastore stub.
    self.datastore_file = os.path.join(self.tmpdir, 'datastore_v3')
    self.history_file = os.path.join(self.tmpdir, 'history')
    for filename in [self.datastore_file, self.history_file]:
      if os.access(filename, os.F_OK):
        os.remove(filename)

    self.datastore_stub = datastore_file_stub.DatastoreFileStub(
        'app', self.datastore_file, self.history_file, use_atexit=False)

    self.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    apiproxy_stub_map.apiproxy = self.apiproxy
    apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', self.datastore_stub)
    apiproxy_stub_map.apiproxy.RegisterStub('blobstore', self.blobstore_stub) 
开发者ID:elsigh,项目名称:browserscope,代码行数:36,代码来源:blob_download_test.py

示例7: PortAllEntities

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def PortAllEntities(datastore_path):
  """Copies entities from a DatastoreFileStub to an SQLite stub.

  Args:
    datastore_path: Path to the file to store Datastore file stub data is.
  """

  previous_stub = apiproxy_stub_map.apiproxy.GetStub('datastore_v3')

  try:
    app_id = os.environ['APPLICATION_ID']
    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    datastore_stub = datastore_file_stub.DatastoreFileStub(
        app_id, datastore_path, trusted=True)
    apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore_stub)

    entities = FetchAllEntitites()
    sqlite_datastore_stub = datastore_sqlite_stub.DatastoreSqliteStub(app_id,
                            datastore_path + '.sqlite', trusted=True)
    apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3',
                                           sqlite_datastore_stub)
    PutAllEntities(entities)
    sqlite_datastore_stub.Close()
  finally:
    apiproxy_stub_map.apiproxy.ReplaceStub('datastore_v3', previous_stub)

  shutil.copy(datastore_path, datastore_path + '.filestub')
  _RemoveFile(datastore_path)
  shutil.move(datastore_path + '.sqlite', datastore_path) 
开发者ID:elsigh,项目名称:browserscope,代码行数:31,代码来源:dev_appserver.py

示例8: setUp

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setUp(self):
        # fix enviroment
        app_id = 'myapp'
        os.environ['APPLICATION_ID'] = app_id
        apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
        stub = datastore_file_stub.DatastoreFileStub(app_id, '/dev/null', '/')
        apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)

        # activate mock services
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_user_stub()
        self.testbed.init_memcache_stub() 
开发者ID:felipevolpone,项目名称:ray,代码行数:15,代码来源:gae_test.py

示例9: Register

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def Register(stub):
  """Insert stubs so App Engine services are accessed via the service bridge."""
  apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap(stub) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:5,代码来源:vmstub.py

示例10: setUp

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setUp(self):
    unittest.TestCase.setUp(self)

    namespace_range._setup_constants('abc', 3, 3)
    self.app_id = 'testapp'
    os.environ['APPLICATION_ID'] = self.app_id
    self.datastore = datastore_file_stub.DatastoreFileStub(
        self.app_id, '/dev/null', '/dev/null')

    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', self.datastore)
    namespace_manager.set_namespace(None) 
开发者ID:GoogleCloudPlatform,项目名称:appengine-mapreduce,代码行数:14,代码来源:namespace_range_test.py

示例11: createLogs

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def createLogs(self, count=10):
    """Create a set of test log records."""
    # Prepare the data.
    apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
    stub = logservice_stub.LogServiceStub()
    apiproxy_stub_map.apiproxy.RegisterStub("logservice", stub)

    # Write test data.
    expected = []
    for i in xrange(count):
      stub.start_request(request_id=i,
                         user_request_id="",
                         ip="127.0.0.1",
                         app_id=self.app_id,
                         version_id=self.version_id,
                         nickname="test@example.com",
                         user_agent="Chrome/15.0.874.106",
                         host="127.0.0.1:8080",
                         method="GET",
                         resource="/",
                         http_version="HTTP/1.1",
                         start_time=i * 1000000)
      stub.end_request(i, 200, 0, end_time=i * 1000000 + 500)
      expected.append({"start_time": i, "end_time": i + .0005})
    expected.reverse()  # Results come back in most-recent-first order.

    return expected 
开发者ID:GoogleCloudPlatform,项目名称:appengine-mapreduce,代码行数:29,代码来源:input_readers_test.py

示例12: setup

# 需要导入模块: from google.appengine.api import apiproxy_stub_map [as 别名]
# 或者: from google.appengine.api.apiproxy_stub_map import APIProxyStubMap [as 别名]
def setup():
  """Setup for all tests in tests/"""
  # Create a new apiproxy and temp datastore to use for this test suite
  apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
  temp_db = datastore_file_stub.DatastoreFileStub(
      'PfifToolsUnittestDataStore', None, None, trusted=True)
  apiproxy_stub_map.apiproxy.RegisterStub('datastore', temp_db)

  # An application id is required to access the datastore, so let's create one
  os.environ['APPLICATION_ID'] = 'pfif-tools-test' 
开发者ID:google,项目名称:personfinder,代码行数:12,代码来源:__init__.py


注:本文中的google.appengine.api.apiproxy_stub_map.APIProxyStubMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。