當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。