本文整理匯總了Python中google.appengine.datastore.datastore_stub_util.PseudoRandomHRConsistencyPolicy方法的典型用法代碼示例。如果您正苦於以下問題:Python datastore_stub_util.PseudoRandomHRConsistencyPolicy方法的具體用法?Python datastore_stub_util.PseudoRandomHRConsistencyPolicy怎麽用?Python datastore_stub_util.PseudoRandomHRConsistencyPolicy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.appengine.datastore.datastore_stub_util
的用法示例。
在下文中一共展示了datastore_stub_util.PseudoRandomHRConsistencyPolicy方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def setUp(self):
super(BaseTest, self).setUp()
root_path = '.'
application_id = 'graphene-gae-test'
# First, create an instance of the Testbed class.
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.setup_env(app_id=application_id, overwrite=True)
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=self.datastore_probability)
self.testbed.init_datastore_v3_stub(root_path=root_path, consistency_policy=policy, require_indexes=True)
self.testbed.init_app_identity_stub()
self.testbed.init_blobstore_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(root_path=root_path)
self.testbed.init_urlfetch_stub()
self.storage = cloudstorage_stub.CloudStorageStub(self.testbed.get_stub('blobstore').storage)
self.testbed.init_mail_stub()
self.testbed.init_user_stub()
self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
ndb.get_context().clear_cache()
ndb.get_context().set_cache_policy(lambda x: True)
示例2: setUp
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def setUp(self):
super(GCSFileSegReaderTest, self).setUp()
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_app_identity_stub()
self.testbed.init_blobstore_stub()
# HRD with no eventual consistency.
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
self.testbed.init_datastore_v3_stub(consistency_policy=policy)
self.testbed.init_memcache_stub()
self.testbed.init_urlfetch_stub()
self.writer_cls = output_writers._GoogleCloudStorageOutputWriter
self.seg_prefix = "/bucket/prefix-"
示例3: setup_testbed
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def setup_testbed():
"""Sets up the GAE testbed and enables common stubs."""
from google.appengine.datastore import datastore_stub_util
from google.appengine.ext import testbed as gaetestbed
# Setup the datastore and memcache stub.
# First, create an instance of the Testbed class.
tb = gaetestbed.Testbed()
# Then activate the testbed, which prepares the service stubs for
# use.
tb.activate()
# Create a consistency policy that will simulate the High
# Replication consistency model.
policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(
probability=1.0)
# Initialize the datastore stub with this policy.
tb.init_datastore_v3_stub(
datastore_file=tempfile.mkstemp()[1],
consistency_policy=policy)
tb.init_memcache_stub()
# Setup remaining stubs.
tb.init_urlfetch_stub()
tb.init_app_identity_stub()
tb.init_blobstore_stub()
tb.init_user_stub()
tb.init_logservice_stub()
# tb.init_taskqueue_stub(root_path='tests/resources')
tb.init_taskqueue_stub()
tb.taskqueue_stub = tb.get_stub(gaetestbed.TASKQUEUE_SERVICE_NAME)
return tb
示例4: _get_api_server
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def _get_api_server(app_id):
"""Return a configured and started api_server.APIServer."""
tmp_dir = tempfile.mkdtemp()
os.environ['APPLICATION_ID'] = app_id
api_server.setup_stubs(
request_data=APIRequestInfo(),
app_id=app_id,
application_root=os.getcwd(),
trusted=False,
appidentity_email_address=None,
appidentity_private_key_path=None,
blobstore_path=tmp_dir,
datastore_consistency=
datastore_stub_util.PseudoRandomHRConsistencyPolicy(),
datastore_path=':memory:',
datastore_require_indexes=False,
datastore_auto_id_policy=datastore_stub_util.SCATTERED,
images_host_prefix='http://localhost:8080',
logs_path=':memory:',
mail_smtp_host='',
mail_smtp_port=25,
mail_smtp_user='',
mail_smtp_password='',
mail_enable_sendmail=False,
mail_show_mail_body=False,
mail_allow_tls=False,
search_index_path=None,
taskqueue_auto_run_tasks=False,
taskqueue_default_http_server='http://localhost:8080',
user_login_url='/_ah/login?continue=%s',
user_logout_url='/_ah/login?continue=%s',
default_gcs_bucket_name=None)
server = api_server.APIServer('localhost', 0, app_id)
server.start()
return server
示例5: test_setup_stubs
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def test_setup_stubs(
request_data=None,
app_id='myapp',
application_root='/tmp/root',
trusted=False,
blobstore_path='/dev/null',
datastore_consistency=None,
datastore_path=':memory:',
datastore_require_indexes=False,
datastore_auto_id_policy=datastore_stub_util.SCATTERED,
images_host_prefix='http://localhost:8080',
logs_path=':memory:',
mail_smtp_host='',
mail_smtp_port=25,
mail_smtp_user='',
mail_smtp_password='',
mail_enable_sendmail=False,
mail_show_mail_body=False,
matcher_prospective_search_path='/dev/null',
search_index_path=None,
taskqueue_auto_run_tasks=False,
taskqueue_default_http_server='http://localhost:8080',
user_login_url='/_ah/login?continue=%s',
user_logout_url='/_ah/login?continue=%s'):
"""Similar to setup_stubs with reasonable test defaults and recallable."""
# Reset the stub map between requests because a stub map only allows a
# stub to be added once.
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
if datastore_consistency is None:
datastore_consistency = (
datastore_stub_util.PseudoRandomHRConsistencyPolicy())
setup_stubs(request_data,
app_id,
application_root,
trusted,
blobstore_path,
datastore_consistency,
datastore_path,
datastore_require_indexes,
datastore_auto_id_policy,
images_host_prefix,
logs_path,
mail_smtp_host,
mail_smtp_port,
mail_smtp_user,
mail_smtp_password,
mail_enable_sendmail,
mail_show_mail_body,
matcher_prospective_search_path,
search_index_path,
taskqueue_auto_run_tasks,
taskqueue_default_http_server,
user_login_url,
user_logout_url)
示例6: setUp
# 需要導入模塊: from google.appengine.datastore import datastore_stub_util [as 別名]
# 或者: from google.appengine.datastore.datastore_stub_util import PseudoRandomHRConsistencyPolicy [as 別名]
def setUp(self):
"""Initializes the commonly used stubs.
Using init_all_stubs() costs ~10ms more to run all the tests so only enable
the ones known to be required. Test cases requiring more stubs can enable
them in their setUp() function.
"""
super(TestCase, self).setUp()
self.testbed = testbed.Testbed()
self.testbed.activate()
# If you have a NeedIndexError, here is the switch you need to flip to make
# the new required indexes to be automatically added. Change
# train_index_yaml to True to have index.yaml automatically updated, then
# run your test case. Do not forget to put it back to False.
train_index_yaml = False
if self.SKIP_INDEX_YAML_CHECK:
# See comment for skip_index_yaml_check above.
self.assertIsNone(self.APP_DIR)
self.testbed.init_app_identity_stub()
self.testbed.init_datastore_v3_stub(
require_indexes=not train_index_yaml and not self.SKIP_INDEX_YAML_CHECK,
root_path=self.APP_DIR,
consistency_policy=datastore_stub_util.PseudoRandomHRConsistencyPolicy(
probability=1))
self.testbed.init_logservice_stub()
self.testbed.init_memcache_stub()
self.testbed.init_modules_stub()
# Use mocked time in memcache.
memcache = self.testbed.get_stub(testbed.MEMCACHE_SERVICE_NAME)
memcache._gettime = lambda: int(utils.time_time())
# Email support.
self.testbed.init_mail_stub()
self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)
self.old_send_to_admins = self.mock(
self.mail_stub, '_Dynamic_SendToAdmins', self._SendToAdmins)
self.testbed.init_taskqueue_stub()
self._taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
self._taskqueue_stub._root_path = self.APP_DIR
self.testbed.init_user_stub()