Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / test / ispy / server / rebaseline_handler.py
blob81bdb4b72442b90a04de64c3c36f16d909cd9513
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Request Handler that updates the Expectation version."""
7 import webapp2
9 import ispy_api
10 from common import constants
12 import gs_bucket
15 class RebaselineHandler(webapp2.RequestHandler):
16 """Request handler to allow test mask updates."""
18 def post(self):
19 """Accepts post requests.
21 Expects a test_run as a parameter and updates the associated version file to
22 use the expectations associated with that test run.
23 """
24 test_run = self.request.get('test_run')
26 # Fail if test_run parameter is missing.
27 if not test_run:
28 self.response.headers['Content-Type'] = 'json/application'
29 self.response.write(json.dumps(
30 {'error': '\'test_run\' must be supplied to rebaseline.'}))
31 return
32 # Otherwise, set up the utilities.
33 bucket = gs_bucket.GoogleCloudStorageBucket(constants.BUCKET)
34 ispy = ispy_api.ISpyApi(bucket)
35 # Update versions file.
36 ispy.RebaselineToTestRun(test_run)
37 # Redirect back to the sites list for the test run.
38 self.redirect('/?test_run=%s' % test_run)