当前位置: 首页>>代码示例>>Python>>正文


Python server.app方法代码示例

本文整理汇总了Python中server.app方法的典型用法代码示例。如果您正苦于以下问题:Python server.app方法的具体用法?Python server.app怎么用?Python server.app使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server的用法示例。


在下文中一共展示了server.app方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def setUp(self):
    test_helpers.patch(self, [
        'libs.issue_management.issue_tracker_utils.get_issue_url',
        'libs.helpers.get_testcase',
        'metrics.logs._is_running_on_app_engine',
    ])
    self.mock._is_running_on_app_engine.return_value = True  # pylint: disable=protected-access

    import server
    self.app = webtest.TestApp(server.app) 
开发者ID:google,项目名称:clusterfuzz,代码行数:12,代码来源:issue_redirector_test.py

示例2: test_succeed

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def test_succeed(self):
    """Test redirection succeeds."""
    testcase = data_types.Testcase()
    testcase.bug_information = '456789'
    self.mock.get_testcase.return_value = testcase
    self.mock.get_issue_url.return_value = 'http://google.com/456789'

    response = self.app.get('/issue/12345')

    self.assertEqual(302, response.status_int)
    self.assertEqual('http://google.com/456789', response.headers['Location'])

    self.mock.get_testcase.assert_has_calls([mock.call('12345')])
    self.mock.get_issue_url.assert_has_calls([mock.call(testcase)]) 
开发者ID:google,项目名称:clusterfuzz,代码行数:16,代码来源:issue_redirector_test.py

示例3: test_no_issue_url

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def test_no_issue_url(self):
    """Test no issue url."""
    self.mock.get_testcase.return_value = data_types.Testcase()
    self.mock.get_issue_url.return_value = ''

    response = self.app.get('/issue/12345', expect_errors=True)
    self.assertEqual(404, response.status_int) 
开发者ID:google,项目名称:clusterfuzz,代码行数:9,代码来源:issue_redirector_test.py

示例4: test

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def test(self):
    import server
    self.assertIsNotNone(server._ROUTES)
    self.assertIsNotNone(server._CRON_ROUTES)
    self.assertIsNotNone(server._DOMAIN_ROUTES)
    self.assertIsNotNone(server.app) 
开发者ID:google,项目名称:clusterfuzz,代码行数:8,代码来源:server_test.py

示例5: _request_json

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def _request_json(url, test_handler):
  """ Utility method to check a JSON is returned from the given URL """
  request = webapp2.Request.blank(url)
  response = request.get_response(server.app)
  test_handler.assertEqual(response.status_int, 200)
  test_handler.assertEqual(response.content_type, 'application/json')
  j = json.loads(response.text)
  return j 
开发者ID:verejnedigital,项目名称:verejne.digital,代码行数:10,代码来源:test.py

示例6: _request_json

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def _request_json(url, test_handler):
    """Verifies that the given URL returns a valid JSON."""
    request = webapp2.Request.blank(url)
    response = request.get_response(server.app)
    test_handler.assertEqual(response.status_int, 200)
    test_handler.assertEqual(response.content_type, 'application/json')
    j = json.loads(response.text)
    return j 
开发者ID:verejnedigital,项目名称:verejne.digital,代码行数:10,代码来源:test.py

示例7: test_many

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def test_many(self):
        """Tests API calls with multiple eid (pairs)."""

        # Query the database for the number of entities.
        db = server.app.registry['db']
        num_entities = db.query('SELECT COUNT(*) FROM entities;',
                                return_dicts=False)[0][0]
        print("Number of entities: %d " % num_entities)

        # Construct a list of multiple entities.
        num_evenly = 5
        eids = list(range(1, num_entities + 1, num_entities // num_evenly))

        for eid in eids:
            print(eid)

            # Test notable_connections:
            url = '/notable_connections?eid=%d' % eid
            content = _request_json(url, self)
            self.assertIsInstance(content, dict)
            self.assertTrue('vertices' in content)
            self.assertTrue('edges' in content)

            for other_eid in eids:
                # Test a_shortest_path:
                url = '/a_shortest_path?eid1=%d&eid2=%d' % (eid, other_eid)
                content = _request_json(url, self)
                self.assertIsInstance(content, list)

                # Test subgraph:
                url = '/subgraph?eid1=%d&eid2=%d' % (eid, other_eid)
                content = _request_json(url, self)
                self.assertIsInstance(content, dict)
                self.assertTrue('vertices' in content)
                self.assertTrue('edges' in content) 
开发者ID:verejnedigital,项目名称:verejne.digital,代码行数:37,代码来源:test.py

示例8: _request_json

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def _request_json(url, test_handler):
    """Utility method to check a JSON is returned from the given URL."""
    request = webapp2.Request.blank(url)
    response = request.get_response(server.app)
    test_handler.assertEqual(response.status_int, 200)
    test_handler.assertEqual(response.content_type, 'application/json')
    j = json.loads(response.text)
    return j 
开发者ID:verejnedigital,项目名称:verejne.digital,代码行数:10,代码来源:test.py

示例9: _request_json

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def _request_json(url, test_handler):
  """Verifies that the given URL returns a valid JSON."""
  request = webapp2.Request.blank(url)
  response = request.get_response(server.app)
  test_handler.assertEqual(response.status_int, 200)
  test_handler.assertEqual(response.content_type, 'application/json')
  j = json.loads(response.text)
  return j 
开发者ID:verejnedigital,项目名称:verejne.digital,代码行数:10,代码来源:test.py

示例10: create_app

# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def create_app(self):
        app = server.app
        app.config['TESTING'] = True
        return app 
开发者ID:alvarocavalcanti,项目名称:pierre-decheck,代码行数:6,代码来源:pierre.py


注:本文中的server.app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。