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

Side by Side Diff: tests/pending_manager_test.py

Issue 138133014: Revert of CQ to always post a message when Commit box is unchecked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Created 6 years, 10 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
« no previous file with comments | « pending_manager.py ('k') | verification/fake.py » ('j') | 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 pending_manager.py.""" 6 """Unit tests for pending_manager.py."""
7 7
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 'close_issue(%d)' % issue, 107 'close_issue(%d)' % issue,
108 "update_description(%d, u'foo')" % issue, 108 "update_description(%d, u'foo')" % issue,
109 "add_comment(%d, 'Change committed as 125')" % issue]) 109 "add_comment(%d, 'Change committed as 125')" % issue])
110 else: 110 else:
111 self.context.checkout.check_calls( 111 self.context.checkout.check_calls(
112 [ 'prepare(None)', 112 [ 'prepare(None)',
113 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],)]) 113 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],)])
114 self.context.rietveld.check_calls( 114 self.context.rietveld.check_calls(
115 [ _try_comment(), 115 [ _try_comment(),
116 "set_flag(%d, 1, 'commit', False)" % issue, 116 "set_flag(%d, 1, 'commit', False)" % issue,
117 "add_comment(%d, %r)" % (issue, fake.failed_message())]) 117 "add_comment(%d, %r)" % (issue, pc.FAILED_NO_MESSAGE)])
118 else: 118 else:
119 if success: 119 if success:
120 self.context.checkout.check_calls( 120 self.context.checkout.check_calls(
121 self._prepare_apply_commit(0, issue)) 121 self._prepare_apply_commit(0, issue))
122 self.context.rietveld.check_calls( 122 self.context.rietveld.check_calls(
123 [ _try_comment(), 123 [ _try_comment(),
124 'close_issue(%d)' % issue, 124 'close_issue(%d)' % issue,
125 "update_description(%d, u'foo')" % issue, 125 "update_description(%d, u'foo')" % issue,
126 "add_comment(%d, 'Change committed as 125')" % issue]) 126 "add_comment(%d, 'Change committed as 125')" % issue])
127 else: 127 else:
128 # checkout is never touched in that case. 128 # checkout is never touched in that case.
129 self.context.checkout.check_calls([]) 129 self.context.checkout.check_calls([])
130 if defered: 130 if defered:
131 self.context.rietveld.check_calls( 131 self.context.rietveld.check_calls(
132 [ _try_comment(), 132 [ _try_comment(),
133 "set_flag(%d, 1, 'commit', False)" % issue, 133 "set_flag(%d, 1, 'commit', False)" % issue,
134 "add_comment(%d, %r)" % (issue, fake.failed_message())]) 134 "add_comment(%d, %r)" % (issue, pc.FAILED_NO_MESSAGE)])
135 else: 135 else:
136 self.context.rietveld.check_calls( 136 self.context.rietveld.check_calls(
137 [ "set_flag(%d, 1, 'commit', False)" % issue, 137 [ "set_flag(%d, 1, 'commit', False)" % issue,
138 "add_comment(%d, %r)" % (issue, fake.failed_message())]) 138 "add_comment(%d, %r)" % (issue, pc.FAILED_NO_MESSAGE)])
139 139
140 def _prepare_apply_commit(self, index, issue, server_hooks_missing=False): 140 def _prepare_apply_commit(self, index, issue, server_hooks_missing=False):
141 """Returns a frequent sequence of action happening on the Checkout object. 141 """Returns a frequent sequence of action happening on the Checkout object.
142 142
143 The list returned by this function should be used as an argument to 143 The list returned by this function should be used as an argument to
144 self.context.checkout.check_calls(). 144 self.context.checkout.check_calls().
145 """ 145 """
146 seq = [ 146 seq = [
147 # Reverts any previous modification or checkout the tree if it was not 147 # Reverts any previous modification or checkout the tree if it was not
148 # present. 148 # present.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 pc.process_new_pending_commit() 258 pc.process_new_pending_commit()
259 self.assertEqual([], pc.queue.iterate()) 259 self.assertEqual([], pc.queue.iterate())
260 pc.update_status() 260 pc.update_status()
261 self.assertEqual([], pc.queue.iterate()) 261 self.assertEqual([], pc.queue.iterate())
262 self.context.checkout.check_calls( 262 self.context.checkout.check_calls(
263 [ 'prepare(None)', 263 [ 'prepare(None)',
264 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],), 264 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],),
265 ]) 265 ])
266 self.context.rietveld.check_calls( 266 self.context.rietveld.check_calls(
267 [ _try_comment(), 267 [ _try_comment(),
268 "add_comment(%d, %r)" % (issue, fake.failed_message()), 268 "add_comment(%d, %r)" % (issue, pc.FAILED_NO_MESSAGE),
269 ]) 269 ])
270 self.context.status.check_names(['initial', 'abort']) 270 self.context.status.check_names(['initial', 'abort'])
271 271
272 def _check_defer_1(self, pc, result): 272 def _check_defer_1(self, pc, result):
273 issue = 31337 273 issue = 31337
274 self.assertEqual(len(pc.queue.iterate()), 0) 274 self.assertEqual(len(pc.queue.iterate()), 0)
275 pc.look_for_new_pending_commit() 275 pc.look_for_new_pending_commit()
276 self.assertEqual(len(pc.queue.iterate()), 1) 276 self.assertEqual(len(pc.queue.iterate()), 1)
277 commit = pc.queue.get(issue) 277 commit = pc.queue.get(issue)
278 self.assertEqual(len(commit.verifications), 0) 278 self.assertEqual(len(commit.verifications), 0)
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 pc.scan_results() 564 pc.scan_results()
565 self.context.rietveld.check_calls( 565 self.context.rietveld.check_calls(
566 [ _try_comment(), 566 [ _try_comment(),
567 'close_issue(%d)' % issue, 567 'close_issue(%d)' % issue,
568 "update_description(%d, u'foo')" % issue, 568 "update_description(%d, u'foo')" % issue,
569 "add_comment(%d, 'Change committed as 125')" % issue]) 569 "add_comment(%d, 'Change committed as 125')" % issue])
570 self.context.status.check_names(['initial', 'why not', 'commit']) 570 self.context.status.check_names(['initial', 'why not', 'commit'])
571 self.context.checkout.check_calls( 571 self.context.checkout.check_calls(
572 self._prepare_apply_commit(0, issue, server_hooks_missing=True)) 572 self._prepare_apply_commit(0, issue, server_hooks_missing=True))
573 573
574 def testDisappeared(self): 574 def testDisapeared(self):
575 issue = 31337 575 issue = 31337
576 verifiers = [ 576 verifiers = [
577 project_base.ProjectBaseUrlVerifier( 577 project_base.ProjectBaseUrlVerifier(
578 [r'^%s(.*)$' % re.escape(r'http://example.com/')]), 578 [r'^%s(.*)$' % re.escape(r'http://example.com/')]),
579 ] 579 ]
580 pc = self._get_pc(verifiers, []) 580 pc = self._get_pc(verifiers, [])
581 pc.context.rietveld.issues[issue]['base_url'] = 'http://unrelated.com/sub' 581 pc.context.rietveld.issues[issue]['base_url'] = 'http://unrelated.com/sub'
582 pc.look_for_new_pending_commit() 582 pc.look_for_new_pending_commit()
583 pc.process_new_pending_commit() 583 pc.process_new_pending_commit()
584 pc.update_status() 584 pc.update_status()
585 pc.scan_results() 585 pc.scan_results()
586 self.assertEqual(1, len(pc.queue.iterate())) 586 self.assertEqual(1, len(pc.queue.iterate()))
587 del pc.context.rietveld.issues[issue] 587 del pc.context.rietveld.issues[issue]
588 pc.look_for_new_pending_commit() 588 pc.look_for_new_pending_commit()
589 pc.process_new_pending_commit() 589 pc.process_new_pending_commit()
590 pc.update_status() 590 pc.update_status()
591 pc.scan_results() 591 pc.scan_results()
592 self.assertEqual(0, len(pc.queue.iterate())) 592 self.assertEqual(0, len(pc.queue.iterate()))
593 self.context.status.check_names(['abort']) 593 self.context.status.check_names(['abort'])
594 self.context.rietveld.check_calls(
595 ["add_comment(%d, 'CQ bit was unchecked on CL. Ignoring.')" % issue])
596 594
597 def _get_pc_reviewer(self): 595 def _get_pc_reviewer(self):
598 verifiers = [ 596 verifiers = [
599 reviewer_lgtm.ReviewerLgtmVerifier( 597 reviewer_lgtm.ReviewerLgtmVerifier(
600 ['.*'], [re.escape('commit-bot@example.com')]) 598 ['.*'], [re.escape('commit-bot@example.com')])
601 ] 599 ]
602 pc = self._get_pc(verifiers, []) 600 pc = self._get_pc(verifiers, [])
603 return pc 601 return pc
604 602
605 def _approve(self, sender=None): 603 def _approve(self, sender=None):
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 self.context.checkout.check_calls( 723 self.context.checkout.check_calls(
726 self._prepare_apply_commit(0, issue)) 724 self._prepare_apply_commit(0, issue))
727 725
728 726
729 if __name__ == '__main__': 727 if __name__ == '__main__':
730 logging.basicConfig( 728 logging.basicConfig(
731 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 729 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
732 min(sys.argv.count('-v'), 3)], 730 min(sys.argv.count('-v'), 3)],
733 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') 731 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
734 unittest.main() 732 unittest.main()
OLDNEW
« no previous file with comments | « pending_manager.py ('k') | verification/fake.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698