Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: chrome/test/functional/ispy/common/ispy_utils.py

Issue 106523003: [I-Spy] Add support for rebaselining expectations from the web UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing dom.py Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Utilities for managing I-Spy test results in Google Cloud Storage.""" 5 """Internal utilities for managing I-Spy test results in Google Cloud Storage.
6
7 See the ispy.client.chrome_utils module for the external API.
8 """
6 9
7 import collections 10 import collections
8 import itertools 11 import itertools
9 import json 12 import json
10 import os 13 import os
11 import sys 14 import sys
12 15
13 import image_tools 16 import image_tools
14 17
15 18
(...skipping 21 matching lines...) Expand all
37 """Get the path to a failure file in the given test run and test. 40 """Get the path to a failure file in the given test run and test.
38 41
39 Args: 42 Args:
40 test_run: name of the test run. 43 test_run: name of the test run.
41 expectation: name of the expectation. 44 expectation: name of the expectation.
42 file_name: name of the file. 45 file_name: name of the file.
43 46
44 Returns: 47 Returns:
45 the path as a string relative to the bucket. 48 the path as a string relative to the bucket.
46 """ 49 """
47 return 'failures/%s/%s/%s' % (test_run, expectation, file_name) 50 return GetTestRunPath(test_run, '%s/%s' % (expectation, file_name))
51
52
53 def GetTestRunPath(test_run, file_name=''):
54 """Get the path to a the given test run.
55
56 Args:
57 test_run: name of the test run.
58 file_name: name of the file.
59
60 Returns:
61 the path as a string relative to the bucket.
62 """
63 return 'failures/%s/%s' % (test_run, file_name)
48 64
49 65
50 class ISpyUtils(object): 66 class ISpyUtils(object):
51 """Utility functions for working with an I-Spy google storage bucket.""" 67 """Utility functions for working with an I-Spy google storage bucket."""
52 68
53 def __init__(self, cloud_bucket): 69 def __init__(self, cloud_bucket):
54 """Initialize with a cloud bucket instance to supply GS functionality. 70 """Initialize with a cloud bucket instance to supply GS functionality.
55 71
56 Args: 72 Args:
57 cloud_bucket: An object implementing the cloud_bucket.BaseCloudBucket 73 cloud_bucket: An object implementing the cloud_bucket.BaseCloudBucket
(...skipping 27 matching lines...) Expand all
85 101
86 def UpdateImage(self, full_path, image): 102 def UpdateImage(self, full_path, image):
87 """Updates an existing image in GS, preserving permissions and metadata. 103 """Updates an existing image in GS, preserving permissions and metadata.
88 104
89 Args: 105 Args:
90 full_path: the path to the file in GS including the file extension. 106 full_path: the path to the file in GS including the file extension.
91 image: a RGB PIL.Image. 107 image: a RGB PIL.Image.
92 """ 108 """
93 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image)) 109 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image))
94 110
95
96 def GenerateExpectation(self, expectation, images): 111 def GenerateExpectation(self, expectation, images):
97 """Creates and uploads an expectation to GS from a set of images and name. 112 """Creates and uploads an expectation to GS from a set of images and name.
98 113
99 This method generates a mask from the uploaded images, then 114 This method generates a mask from the uploaded images, then
100 uploads the mask and first of the images to GS as a expectation. 115 uploads the mask and first of the images to GS as a expectation.
101 116
102 Args: 117 Args:
103 expectation: name for this expectation, any existing expectation with the 118 expectation: name for this expectation, any existing expectation with the
104 name will be replaced. 119 name will be replaced.
105 images: a list of RGB encoded PIL.Images 120 images: a list of RGB encoded PIL.Images
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 295
281 Args: 296 Args:
282 prefix: the prefix to filter files in GS by. 297 prefix: the prefix to filter files in GS by.
283 298
284 Returns: 299 Returns:
285 a list containing urls to all objects that started with 300 a list containing urls to all objects that started with
286 the prefix. 301 the prefix.
287 """ 302 """
288 return self.cloud_bucket.GetAllPaths(prefix) 303 return self.cloud_bucket.GetAllPaths(prefix)
289 304
OLDNEW
« no previous file with comments | « chrome/test/functional/ispy/common/chrome_utils_unittest.py ('k') | chrome/test/functional/ispy/server/app.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698