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

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

Issue 2400453002: [Findit] Retrieve recent builds of a given builder. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « appengine/findit/waterfall/buildbot.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 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 from datetime import datetime 5 from datetime import datetime
6 import mock 6 import mock
7 import os 7 import os
8 import unittest 8 import unittest
9 9
10 from common.retry_http_client import RetryHttpClient 10 from common.retry_http_client import RetryHttpClient
(...skipping 17 matching lines...) Expand all
28 28
29 def _Post(self, *_): # pragma: no cover 29 def _Post(self, *_): # pragma: no cover
30 pass 30 pass
31 31
32 def _Put(self, *_): # pragma: no cover 32 def _Put(self, *_): # pragma: no cover
33 pass 33 pass
34 34
35 35
36 class BuildBotTest(unittest.TestCase): 36 class BuildBotTest(unittest.TestCase):
37 37
38 def testFailToGetRecentCompletedBuilds(self):
39 mocked_http_client = mock.Mock()
40 mocked_http_client.Get.side_effect = [(404, '404'), None]
41 self.assertEqual(
42 [], buildbot.GetRecentCompletedBuilds('m', 'b', mocked_http_client))
43 mocked_http_client.assert_has_calls(
44 mock.call('https://build.chromium.org/p/m/json/builders/'))
45
46 def testGetRecentCompletedBuilds(self):
47 builders_json_data = """
48 {
49 "b": {
50 "cachedBuilds": [33, 32, 34, 35],
51 "currentBuilds": [35]
52 }
53 }
54 """
55 mocked_http_client = mock.Mock()
56 mocked_http_client.Get.return_value = (200, builders_json_data)
57 self.assertEqual(
58 [34, 33, 32],
59 buildbot.GetRecentCompletedBuilds('m', 'b', mocked_http_client))
60 mocked_http_client.assert_has_calls(
61 mock.call('https://build.chromium.org/p/m/json/builders/'))
62
38 def testGetMasternameFromUrl(self): 63 def testGetMasternameFromUrl(self):
39 cases = { 64 cases = {
40 None: None, 65 None: None,
41 '': None, 66 '': None,
42 'https://unknown.host/p/chromium': None, 67 'https://unknown.host/p/chromium': None,
43 'http://build.chromium.org/p/chromium': 'chromium', 68 'http://build.chromium.org/p/chromium': 'chromium',
44 'http://build.chromium.org/p/chromium/builders/Linux': 'chromium', 69 'http://build.chromium.org/p/chromium/builders/Linux': 'chromium',
45 } 70 }
46 71
47 for url, expected_result in cases.iteritems(): 72 for url, expected_result in cases.iteritems():
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 441
417 expected_blame_list = [ 442 expected_blame_list = [
418 '449cdbd05616de91fcf7e8b4282e300336d6d7c5', 443 '449cdbd05616de91fcf7e8b4282e300336d6d7c5',
419 '6addffac2601ab1083a55d085847d9bf8e66da02' 444 '6addffac2601ab1083a55d085847d9bf8e66da02'
420 ] 445 ]
421 446
422 build_info = buildbot.ExtractBuildInfo( 447 build_info = buildbot.ExtractBuildInfo(
423 master_name, builder_name, build_number, build_data) 448 master_name, builder_name, build_number, build_data)
424 449
425 self.assertEqual(expected_blame_list, build_info.blame_list) 450 self.assertEqual(expected_blame_list, build_info.blame_list)
OLDNEW
« no previous file with comments | « appengine/findit/waterfall/buildbot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698