本文整理汇总了Python中google.appengine.ext.testbed.TASKQUEUE_SERVICE_NAME属性的典型用法代码示例。如果您正苦于以下问题:Python testbed.TASKQUEUE_SERVICE_NAME属性的具体用法?Python testbed.TASKQUEUE_SERVICE_NAME怎么用?Python testbed.TASKQUEUE_SERVICE_NAME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类google.appengine.ext.testbed
的用法示例。
在下文中一共展示了testbed.TASKQUEUE_SERVICE_NAME属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_user_stub()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.testbed.init_urlfetch_stub()
self.testbed.init_mail_stub()
self.testbed.init_taskqueue_stub(
root_path=os.path.join(os.path.dirname(__file__), '..'))
self.addCleanup(self.testbed.deactivate)
self.taskqueue_stub = self.testbed.get_stub(
testbed.TASKQUEUE_SERVICE_NAME)
self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)
urlfetch = self.testbed.get_stub('urlfetch')
urlfetch._RetrieveURL = self.retrieve_mock
self._response_queue = []
self.patch_xsrf()
示例2: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [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)
示例3: test_app
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def test_app(testbed):
key_name = 'foo'
testbed.init_taskqueue_stub(root_path=os.path.dirname(__file__))
app = webtest.TestApp(main.app)
app.post('/', {'key': key_name})
tq_stub = testbed.get_stub(gaetestbed.TASKQUEUE_SERVICE_NAME)
tasks = tq_stub.get_filtered_tasks()
assert len(tasks) == 1
assert tasks[0].name == 'task1'
with mock.patch('main.update_counter') as mock_update:
# Force update to fail, otherwise the loop will go forever.
mock_update.side_effect = RuntimeError()
app.get('/_ah/start', status=500)
assert mock_update.called
示例4: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def setUp(self):
"""Set up the environment for testing."""
super(TestCase, self).setUp()
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.testbed.init_user_stub()
self.testbed.init_search_stub()
self.testbed.init_taskqueue_stub()
self.login_user()
taskqueue_patcher = mock.patch.object(taskqueue, 'add')
self.addCleanup(taskqueue_patcher.stop)
self.taskqueue_add = taskqueue_patcher.start()
self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
# The events.raise_event method raises an exception if there are no events
# in datastore. It's called often in the model methods, many of which are
# used in testing. When you want to test raise_event specifically, first run
# stop() on this patcher; be sure to run start() again before end of test.
def side_effect(event_name, device=None, shelf=None):
"""Side effect for raise_event that returns the model."""
del event_name # Unused.
if device:
return device
else:
return shelf
self.testbed.mock_raiseevent = mock.Mock(side_effect=side_effect)
self.testbed.raise_event_patcher = mock.patch.object(
events, 'raise_event', self.testbed.mock_raiseevent)
self.addCleanup(self.testbed.raise_event_patcher.stop)
self.testbed.raise_event_patcher.start()
示例5: init_webtest
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def init_webtest(self):
self.under_test = webtest.TestApp(routes.app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_memcache_stub()
path = os.path.join(os.path.dirname(__file__), '../config')
logging.debug("queue.yaml path: %s", path)
self.testbed.init_taskqueue_stub(root_path=path)
self.taskqueue_stub = self.testbed.get_stub(
testbed.TASKQUEUE_SERVICE_NAME)
self.testbed.init_app_identity_stub()
示例6: setup_testbed
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [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
示例7: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
# root_path must be set the the location of queue.yaml.
# Otherwise, only the 'default' queue will be available.
self.testbed.init_taskqueue_stub(
root_path=os.path.join(os.path.dirname(__file__), 'resources'))
self.taskqueue_stub = self.testbed.get_stub(
testbed.TASKQUEUE_SERVICE_NAME)
示例8: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def setUp(self):
self.app = webtest.TestApp(main.app)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(
root_path=os.path.join(os.path.dirname(__file__), '../'))
self.taskqueue_stub = self.testbed.get_stub(
testbed.TASKQUEUE_SERVICE_NAME)
示例9: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [as 别名]
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_taskqueue_stub('./gae/')
self.taskqueue_stub = self.testbed.get_stub(
testbed.TASKQUEUE_SERVICE_NAME)
示例10: setUp
# 需要导入模块: from google.appengine.ext import testbed [as 别名]
# 或者: from google.appengine.ext.testbed import TASKQUEUE_SERVICE_NAME [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()