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

Side by Side Diff: appengine/findit/waterfall/test/build_util_test.py

Issue 2597373002: [Findit] Flake checker: Get full build info for each flake build analyzed (Closed)
Patch Set: Removing incorrect line Created 3 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import datetime 5 import datetime
6 6 import json
7 from testing_utils import testing 7 import mock
8 8
9 from model.wf_build import WfBuild 9 from model.wf_build import WfBuild
10 from waterfall import build_util 10 from waterfall import build_util
11 from waterfall import buildbot 11 from waterfall import buildbot
12 from waterfall.test import wf_testcase 12 from waterfall.test import wf_testcase
13 13
14 14
15 class BuildUtilTest(wf_testcase.WaterfallTestCase): 15 class BuildUtilTest(wf_testcase.WaterfallTestCase):
16 16
17 def setUp(self): 17 def setUp(self):
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 master_name = 'm' 190 master_name = 'm'
191 builder_name = 'b' 191 builder_name = 'b'
192 build_number = 1 192 build_number = 1
193 self.assertEqual( 193 self.assertEqual(
194 build_util.CreateBuildId(master_name, builder_name, build_number), 194 build_util.CreateBuildId(master_name, builder_name, build_number),
195 'm/b/1') 195 'm/b/1')
196 196
197 def testGetBuildInfoFromId(self): 197 def testGetBuildInfoFromId(self):
198 build_id = 'm/b/1' 198 build_id = 'm/b/1'
199 self.assertEqual(build_util.GetBuildInfoFromId(build_id), ['m', 'b', '1']) 199 self.assertEqual(build_util.GetBuildInfoFromId(build_id), ['m', 'b', '1'])
200
201 @mock.patch.object(build_util, 'DownloadBuildData')
202 def testGetBuildInfo(self, mocked_fn):
203 build = WfBuild.Create('m', 'b', 123)
204 build.data = json.dumps({
205 'properties': [
206 ['got_revision', 'a_git_hash'],
207 ['got_revision_cp', 'refs/heads/master@{#12345}']
208 ],
209 })
210 mocked_fn.return_value = build
211
212 build_info = build_util.GetBuildInfo('m', 'b', 123)
213 self.assertEqual(build_info.chromium_revision, 'a_git_hash')
214
215 @mock.patch.object(build_util, 'DownloadBuildData')
216 def testGetBuildInfoBuildNotAvailable(self, mocked_fn):
217 master_name = 'm'
218 builder_name = 'b'
219 build_number = 123
220 build = WfBuild.Create(master_name, builder_name, build_number)
221 build.data = {}
222 mocked_fn.return_value = build
223
224 self.assertIsNone(
225 build_util.GetBuildInfo(master_name, builder_name, build_number))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698