本文整理汇总了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)
示例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)])
示例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)
示例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)
示例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
示例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
示例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)
示例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
示例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
示例10: create_app
# 需要导入模块: import server [as 别名]
# 或者: from server import app [as 别名]
def create_app(self):
app = server.app
app.config['TESTING'] = True
return app