Merge "Handle '/' in build_name for getting test_runs"

This commit is contained in:
Zuul 2017-10-02 10:36:30 +00:00 committed by Gerrit Code Review
commit f7143734f8
2 changed files with 10 additions and 4 deletions

View File

@ -273,7 +273,7 @@ def _group_runs_by_key(runs_by_time, groupby_key):
return grouped_runs_by
@app.route('/build_name/<string:build_name>/test_runs', methods=['GET'])
@app.route('/build_name/<path:build_name>/test_runs', methods=['GET'])
def get_test_runs_by_build_name(build_name):
value = parse.unquote(build_name)
if not value:

View File

@ -87,13 +87,13 @@ class TestRestAPI(base.TestCase):
'start_time': timestamp_a,
'stop_time': timestamp_b}
])
def test_get_test_runs_by_build_name(self, api_mock):
def _test_get_test_runs_by_build_name(self, build_name, api_mock):
api.region = mock.MagicMock()
api.region.cache_on_arguments = mock.MagicMock()
api.region.cache_on_arguments.return_value = lambda x: x
res = self.app.get('/build_name/fake_tests/test_runs')
res = self.app.get('/build_name/%s/test_runs' % build_name)
self.assertEqual(200, res.status_code)
api_mock.assert_called_once_with('build_name', 'fake_tests', None,
api_mock.assert_called_once_with('build_name', build_name, None,
None, api.Session())
expected_response = {
six.text_type(timestamp_a.isoformat()): {
@ -112,6 +112,12 @@ class TestRestAPI(base.TestCase):
self.assertEqual({u'tests': expected_response},
json.loads(res.data.decode('utf-8')))
def test_get_test_runs_by_build_name(self):
self._test_get_test_runs_by_build_name('fake_tests')
def test_get_test_runs_by_build_name_with_forward_slash(self):
self._test_get_test_runs_by_build_name('fake/tests')
def test_list_routes(self):
res = self.app.get('/')
res_dict = json.loads(res.data.decode('utf-8'))