Python server.app() Examples
The following are 10
code examples of server.app().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
server
, or try the search function
.
Example #1
Source File: issue_redirector_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
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)
Example #2
Source File: issue_redirector_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
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)])
Example #3
Source File: issue_redirector_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
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)
Example #4
Source File: server_test.py From clusterfuzz with Apache License 2.0 | 5 votes |
def test(self): import server self.assertIsNotNone(server._ROUTES) self.assertIsNotNone(server._CRON_ROUTES) self.assertIsNotNone(server._DOMAIN_ROUTES) self.assertIsNotNone(server.app)
Example #5
Source File: test.py From verejne.digital with Apache License 2.0 | 5 votes |
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
Example #6
Source File: test.py From verejne.digital with Apache License 2.0 | 5 votes |
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
Example #7
Source File: test.py From verejne.digital with Apache License 2.0 | 5 votes |
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)
Example #8
Source File: test.py From verejne.digital with Apache License 2.0 | 5 votes |
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
Example #9
Source File: test.py From verejne.digital with Apache License 2.0 | 5 votes |
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
Example #10
Source File: pierre.py From pierre-decheck with MIT License | 5 votes |
def create_app(self): app = server.app app.config['TESTING'] = True return app