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

Side by Side Diff: tests/presubmit_unittest.py

Issue 11348122: Add presubmit check to verify issue is not closed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years 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
« no previous file with comments | « presubmit_canned_checks.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py."""
7 7
8 # pylint: disable=E1101,E1103 8 # pylint: disable=E1101,E1103
9 9
10 import logging 10 import logging
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 'CheckChangeHasQaField', 'CheckChangeHasTestedField', 1500 'CheckChangeHasQaField', 'CheckChangeHasTestedField',
1501 'CheckChangeHasTestField', 1501 'CheckChangeHasTestField',
1502 'CheckChangeLintsClean', 1502 'CheckChangeLintsClean',
1503 'CheckChangeSvnEolStyle', 1503 'CheckChangeSvnEolStyle',
1504 'CheckChangeWasUploaded', 1504 'CheckChangeWasUploaded',
1505 'CheckDoNotSubmit', 1505 'CheckDoNotSubmit',
1506 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', 1506 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles',
1507 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', 1507 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks',
1508 'CheckLicense', 1508 'CheckLicense',
1509 'CheckOwners', 1509 'CheckOwners',
1510 'CheckIssueNotClosed',
1510 'CheckRietveldTryJobExecution', 1511 'CheckRietveldTryJobExecution',
1511 'CheckSingletonInHeaders', 1512 'CheckSingletonInHeaders',
1512 'CheckSvnModifiedDirectories', 1513 'CheckSvnModifiedDirectories',
1513 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', 1514 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty',
1514 'RunPythonUnitTests', 'RunPylint', 1515 'RunPythonUnitTests', 'RunPylint',
1515 'RunUnitTests', 'RunUnitTestsInDirectory', 1516 'RunUnitTests', 'RunUnitTestsInDirectory',
1516 ] 1517 ]
1517 # If this test fails, you should add the relevant test. 1518 # If this test fails, you should add the relevant test.
1518 self.compareMembers(presubmit_canned_checks, members) 1519 self.compareMembers(presubmit_canned_checks, members)
1519 1520
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 "reviewers": reviewers 2247 "reviewers": reviewers
2247 } 2248 }
2248 2249
2249 if is_committing: 2250 if is_committing:
2250 people = approvers 2251 people = approvers
2251 else: 2252 else:
2252 people = reviewers 2253 people = reviewers
2253 2254
2254 if issue: 2255 if issue:
2255 input_api.rietveld.get_issue_properties( 2256 input_api.rietveld.get_issue_properties(
2256 int(input_api.change.issue), True).AndReturn(rietveld_response) 2257 issue=int(input_api.change.issue), messages=True).AndReturn(
2258 rietveld_response)
2257 people.add(owner_email) 2259 people.add(owner_email)
2258 2260
2259 fake_db.directories_not_covered_by(set(['foo/xyz.cc']), 2261 fake_db.directories_not_covered_by(set(['foo/xyz.cc']),
2260 people).AndReturn(uncovered_dirs) 2262 people).AndReturn(uncovered_dirs)
2261 if not is_committing and uncovered_dirs: 2263 if not is_committing and uncovered_dirs:
2262 fake_db.reviewers_for(set(['foo/xyz.cc'])).AndReturn(owner_email) 2264 fake_db.reviewers_for(set(['foo/xyz.cc'])).AndReturn(owner_email)
2263 2265
2264 self.mox.ReplayAll() 2266 self.mox.ReplayAll()
2265 output = presubmit.PresubmitOutput() 2267 output = presubmit.PresubmitOutput()
2266 results = presubmit_canned_checks.CheckOwners(input_api, 2268 results = presubmit_canned_checks.CheckOwners(input_api,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 'directories:\n' 2389 'directories:\n'
2388 ' foo\n') 2390 ' foo\n')
2389 2391
2390 def testCannedCheckOwners_WithLGTMs(self): 2392 def testCannedCheckOwners_WithLGTMs(self):
2391 self.AssertOwnersWorks(approvers=set(['ben@example.com']), 2393 self.AssertOwnersWorks(approvers=set(['ben@example.com']),
2392 uncovered_dirs=set()) 2394 uncovered_dirs=set())
2393 self.AssertOwnersWorks(approvers=set(['ben@example.com']), 2395 self.AssertOwnersWorks(approvers=set(['ben@example.com']),
2394 is_committing=False, 2396 is_committing=False,
2395 uncovered_dirs=set()) 2397 uncovered_dirs=set())
2396 2398
2399 def CheckIssueClosedBase(self, closed):
2400 input_api = self.MockInputApi(
2401 presubmit.Change('', '', None, None, 1, 0, None), False)
2402 input_api.rietveld.get_issue_properties(
2403 issue=int(input_api.change.issue), messages=False).AndReturn(
2404 {'closed': closed, 'issue': 1})
2405 self.mox.ReplayAll()
2406 return presubmit_canned_checks.CheckIssueNotClosed(
2407 input_api, presubmit.OutputApi)
2408
2409 def testIssueOpen(self):
2410 self.assertEqual([], self.CheckIssueClosedBase(False))
2411
2412 def testIssueClosed(self):
2413 results = self.CheckIssueClosedBase(True)
2414 self.assertEqual(len(results), 1)
2415 self.assertTrue(results[0].fatal)
2416
2397 def testCannedRunUnitTests(self): 2417 def testCannedRunUnitTests(self):
2398 change = presubmit.Change( 2418 change = presubmit.Change(
2399 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None) 2419 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None)
2400 input_api = self.MockInputApi(change, False) 2420 input_api = self.MockInputApi(change, False)
2401 input_api.verbose = True 2421 input_api.verbose = True
2402 unit_tests = ['allo', 'bar.py'] 2422 unit_tests = ['allo', 'bar.py']
2403 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) 2423 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir)
2404 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) 2424 input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir)
2405 input_api.subprocess.check_call( 2425 input_api.subprocess.check_call(
2406 ['allo', '--verbose'], cwd=self.fake_root_dir) 2426 ['allo', '--verbose'], cwd=self.fake_root_dir)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 owners_check=False) 2504 owners_check=False)
2485 self.assertEqual(1, len(results)) 2505 self.assertEqual(1, len(results))
2486 self.assertEqual( 2506 self.assertEqual(
2487 'Found line ending with white spaces in:', results[0]._message) 2507 'Found line ending with white spaces in:', results[0]._message)
2488 self.checkstdout('') 2508 self.checkstdout('')
2489 2509
2490 2510
2491 if __name__ == '__main__': 2511 if __name__ == '__main__':
2492 import unittest 2512 import unittest
2493 unittest.main() 2513 unittest.main()
OLDNEW
« no previous file with comments | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698