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


Python webapp2.WSGIApplication方法代碼示例

本文整理匯總了Python中webapp2.WSGIApplication方法的典型用法代碼示例。如果您正苦於以下問題:Python webapp2.WSGIApplication方法的具體用法?Python webapp2.WSGIApplication怎麽用?Python webapp2.WSGIApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webapp2的用法示例。


在下文中一共展示了webapp2.WSGIApplication方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch(self, [
        'datastore.data_handler.get_issue_description',
        'datastore.data_handler.get_issue_summary',
        'datastore.data_handler.get_stacktrace',
        'datastore.data_handler.update_group_bug',
        'libs.helpers.get_issue_tracker_for_testcase',
        'libs.auth.get_current_user',
        'handlers.testcase_detail.show.get_testcase_detail',
        'libs.access.get_access',
        'libs.issue_management.issue_tracker_policy.get',
        'libs.issue_management.issue_filer.get_memory_tool_labels',
    ])
    self.mock.get_access.return_value = access.UserAccess.Allowed
    self.mock.get_testcase_detail.return_value = {'testcase': 'yes'}
    self.mock.get_current_user().email = 'test@test.com'
    self.mock.get.return_value = CHROMIUM_POLICY

    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/', update_issue.Handler)]))

    self.testcase = data_types.Testcase()
    self.testcase.bug_information = ''
    self.testcase.crash_state = 'fake_crash_state'
    self.testcase.put() 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:27,代碼來源:update_issue_test.py

示例2: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch(self, [
        'base.tasks.add_task',
        'base.tasks.queue_for_job',
        'libs.auth.get_current_user',
        'handlers.testcase_detail.show.get_testcase_detail',
        'libs.access.check_access_and_get_testcase',
    ])
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/', update_from_trunk.Handler)]))

    self.testcase = data_types.Testcase(queue='old-queue')
    self.testcase.put()
    self.mock.check_access_and_get_testcase.return_value = self.testcase
    self.mock.get_testcase_detail.return_value = {'testcase': 'yes'}
    self.mock.get_current_user().email = 'test@user.com' 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:18,代碼來源:update_from_trunk_test.py

示例3: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch(self, [
        'handlers.testcase_detail.show.get_testcase_detail',
        'libs.access.has_access',
        'libs.auth.get_current_user',
        'libs.issue_management.issue_filer.file_issue',
        'libs.issue_management.issue_tracker_utils.'
        'get_issue_tracker_for_testcase',
    ])
    self.mock.has_access.return_value = True
    self.mock.get_testcase_detail.return_value = {'testcase': 'yes'}
    self.mock.get_current_user().email = 'test@user.com'

    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/', create_issue.Handler)]))

    self.testcase = data_types.Testcase()
    self.testcase.put() 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:20,代碼來源:create_issue_test.py

示例4: _test_download

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def _test_download(self, handler_class):
    """Test download."""
    testcase = data_types.Testcase()
    testcase.minimized_keys = 'key'
    testcase.put()

    self.mock.check_access_and_get_testcase.return_value = testcase

    app = webtest.TestApp(webapp2.WSGIApplication([('/', handler_class)]))
    resp = app.get('/?id=%s' % testcase.key.id())

    self.assertEqual(302, resp.status_int)
    # pylint: disable=line-too-long
    # According to https://cloud.google.com/appengine/docs/go/how-requests-are-handled
    # Appengine replaces X-AppEngine-BlobKey with the blob content.
    self.assertEqual(
        'https://SIGNED_URL&response-content-disposition=attachment'
        '%3B+filename%3Dtestcase-1-file.tar.gz', resp.location) 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:20,代碼來源:download_testcase_test.py

示例5: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch(self, [
        'libs.access.check_access_and_get_testcase',
        'libs.issue_management.issue_tracker_utils.'
        'get_issue_tracker_for_testcase',
        'libs.issue_management.issue_tracker_utils.get_issue_url',
        'libs.issue_management.issue_tracker_utils.get_search_keywords',
        'libs.issue_management.issue_tracker_utils.get_similar_issues',
        'libs.issue_management.issue_tracker_utils.get_similar_issues_url',
    ])
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/', find_similar_issues.Handler)]))

    self.testcase = data_types.Testcase()
    self.testcase.put()
    self.mock.check_access_and_get_testcase.return_value = self.testcase

    self.invalid_testcase_id = self.testcase.key.id() + 1 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:20,代碼來源:find_similar_issues_test.py

示例6: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/build-status',
                                  oss_fuzz_build_status.Handler)]))

    test_helpers.patch(self, [
        'base.utils.utcnow',
        'handlers.base_handler.Handler.is_cron',
        'libs.issue_management.issue_tracker_utils.get_issue_tracker',
        'metrics.logs.log_error',
        'requests.get',
    ])

    self.mock.utcnow.return_value = datetime.datetime(2018, 2, 1)
    self.mock.is_cron.return_value = True

    self.itm = IssueTrackerManager('oss-fuzz')
    self.mock.get_issue_tracker.return_value = monorail.IssueTracker(self.itm)

    self.maxDiff = None  # pylint: disable=invalid-name 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:22,代碼來源:oss_fuzz_build_status_test.py

示例7: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch_environ(self)
    test_helpers.patch(self, [
        'handlers.base_handler.Handler.is_cron',
    ])

    self.mock.is_cron.return_value = True
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/generate-certs',
                                  oss_fuzz_generate_certs.Handler)]))

    data_types.OssFuzzProject(name='project1').put()
    data_types.OssFuzzProject(name='project2').put()

    data_types.WorkerTlsCert(
        id='project2',
        project_name='project2',
        cert_contents=b'cert_contents',
        key_contents=b'key_contents').put() 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:21,代碼來源:oss_fuzz_generate_certs_test.py

示例8: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/load-bigquery-stats',
                                  load_bigquery_stats.Handler)]))

    data_types.Fuzzer(name='fuzzer', jobs=['job']).put()
    data_types.Job(name='job').put()

    test_helpers.patch(self, [
        'google_cloud_utils.big_query.get_api_client',
        'handlers.base_handler.Handler.is_cron',
        'handlers.cron.load_bigquery_stats.Handler._utc_now',
    ])

    self.mock._utc_now.return_value = datetime.datetime(2016, 9, 8)  # pylint: disable=protected-access
    self.mock_bigquery = mock.MagicMock()
    self.mock.get_api_client.return_value = self.mock_bigquery 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:19,代碼來源:load_bigquery_stats_test.py

示例9: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    test_helpers.patch(self, [
        'base.external_users._allowed_entities_for_user',
        'base.external_users._get_permissions_query_for_user',
        'libs.access.get_user_job_type',
        'libs.access.has_access',
        'libs.helpers.get_user_email',
    ])
    self.app = webtest.TestApp(
        webapp2.WSGIApplication([('/', testcase_list.JsonHandler)]))

    self.testcases = []
    for i in range(10):
      t = data_types.Testcase()
      t.crash_type = ''
      t.crash_state = ''
      t.status = 'Processed'
      t.security_flag = True
      t.is_a_duplicate_flag = False
      t.one_time_crasher_flag = False
      t.open = True
      t.is_leader = True
      t.timestamp = datetime.datetime.fromtimestamp(100 - i)
      t.put()
      self.testcases.append(t) 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:27,代碼來源:testcase_list_test.py

示例10: get_store

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def get_store(factory=AuthStore, key=_store_registry_key, app=None):
    """Returns an instance of :class:`AuthStore` from the app registry.

    It'll try to get it from the current app registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`AuthStore` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param app:
        A :class:`webapp2.WSGIApplication` instance used to store the instance.
        The active app is used if it is not set.
    """
    app = app or webapp2.get_app()
    store = app.registry.get(key)
    if not store:
        store = app.registry[key] = factory(app)

    return store 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:auth.py

示例11: get_jinja2

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def get_jinja2(factory=Jinja2, key=_registry_key, app=None):
    """Returns an instance of :class:`Jinja2` from the app registry.

    It'll try to get it from the current app registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`Jinja2` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param app:
        A :class:`webapp2.WSGIApplication` instance used to store the instance.
        The active app is used if it is not set.
    """
    app = app or webapp2.get_app()
    jinja2 = app.registry.get(key)
    if not jinja2:
        jinja2 = app.registry[key] = factory(app)

    return jinja2 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:jinja2.py

示例12: __init__

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def __init__(self, app, config=None):
        """Initializes the i18n store.

        :param app:
            A :class:`webapp2.WSGIApplication` instance.
        :param config:
            A dictionary of configuration values to be overridden. See
            the available keys in :data:`default_config`.
        """
        config = app.config.load_config(self.config_key,
            default_values=default_config, user_values=config,
            required_keys=None)
        self.translations = {}
        self.translations_path = config['translations_path']
        self.domains = config['domains']
        self.default_locale = config['default_locale']
        self.default_timezone = config['default_timezone']
        self.date_formats = config['date_formats']
        self.set_locale_selector(config['locale_selector'])
        self.set_timezone_selector(config['timezone_selector']) 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:22,代碼來源:i18n.py

示例13: get_store

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def get_store(factory=I18nStore, key=_store_registry_key, app=None):
    """Returns an instance of :class:`I18nStore` from the app registry.

    It'll try to get it from the current app registry, and if it is not
    registered it'll be instantiated and registered. A second call to this
    function will return the same instance.

    :param factory:
        The callable used to build and register the instance if it is not yet
        registered. The default is the class :class:`I18nStore` itself.
    :param key:
        The key used to store the instance in the registry. A default is used
        if it is not set.
    :param app:
        A :class:`webapp2.WSGIApplication` instance used to store the instance.
        The active app is used if it is not set.
    """
    app = app or webapp2.get_app()
    store = app.registry.get(key)
    if not store:
        store = app.registry[key] = factory(app)

    return store 
開發者ID:google,項目名稱:googleapps-message-recall,代碼行數:25,代碼來源:i18n.py

示例14: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.app = webapp2.WSGIApplication([('/', DummyHandler),
                                        ('/ajax', DummyAjaxHandler),
                                        ('/cron', DummyCronHandler),
                                        ('/task', DummyTaskHandler)]) 
開發者ID:google,項目名稱:gae-secure-scaffold-python,代碼行數:11,代碼來源:handlers_test.py

示例15: setUp

# 需要導入模塊: import webapp2 [as 別名]
# 或者: from webapp2 import WSGIApplication [as 別名]
def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()

    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_urlfetch_stub()

    self.testbed.init_mail_stub()
    self.mail_stub = self.testbed.get_stub(testbed.MAIL_SERVICE_NAME)

    self.mockery = mox.Mox()
    self.stripe = self.mockery.CreateMock(handlers.StripeBackend)
    self.mailing_list_subscriber = self.mockery.CreateMock(
      handlers.MailingListSubscriber)
    self.mail_sender = env.MailSender(defer=False)

    self.env = handlers.Environment(
      app_name='unittest',
      stripe_public_key='pubkey1234',
      stripe_backend=self.stripe,
      mailing_list_subscriber=self.mailing_list_subscriber,
      mail_sender=self.mail_sender)

    from main import HANDLERS  # main import must come after other init
    self.wsgi_app = webapp2.WSGIApplication(HANDLERS + handlers.HANDLERS,
                                            config=dict(env=self.env))

    self.app = webtest.TestApp(self.wsgi_app) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:31,代碼來源:test_e2e.py


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