当前位置: 首页>>代码示例>>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;未经允许,请勿转载。