當前位置: 首頁>>代碼示例>>Python>>正文


Python testbed.TASKQUEUE_SERVICE_NAME屬性代碼示例

本文整理匯總了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() 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:23,代碼來源:__init__.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-gae,代碼行數:26,代碼來源:base_test.py

示例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 
開發者ID:GoogleCloudPlatform,項目名稱:python-docs-samples,代碼行數:22,代碼來源:pullcounter_test.py

示例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() 
開發者ID:google,項目名稱:loaner,代碼行數:36,代碼來源:loanertest.py

示例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() 
開發者ID:ocadotechnology,項目名稱:gcp-census,代碼行數:14,代碼來源:bigquery_handler_test.py

示例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 
開發者ID:GoogleCloudPlatform,項目名稱:python-repo-tools,代碼行數:34,代碼來源:appengine.py

示例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) 
開發者ID:GoogleCloudPlatform,項目名稱:python-docs-samples,代碼行數:12,代碼來源:task_queue_test.py

示例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) 
開發者ID:GoogleCloudPlatform,項目名稱:professional-services,代碼行數:12,代碼來源:main_test.py

示例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) 
開發者ID:WillianFuks,項目名稱:example_dataproc_twitter,代碼行數:8,代碼來源:test_scheduler.py

示例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() 
開發者ID:luci,項目名稱:luci-py,代碼行數:48,代碼來源:test_case.py


注:本文中的google.appengine.ext.testbed.TASKQUEUE_SERVICE_NAME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。