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

Side by Side Diff: commit-queue/tests/pending_manager_test.py

Issue 25088005: GTTF: Restore a change that makes local testing possible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « commit-queue/pending_manager.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 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 [ _try_comment(), 106 [ _try_comment(),
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, pc.FAILED_NO_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, pc.FAILED_NO_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, pc.FAILED_NO_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
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 self.assertEqual(0, len(pc.queue.iterate())) 614 self.assertEqual(0, len(pc.queue.iterate()))
615 pc.look_for_new_pending_commit() 615 pc.look_for_new_pending_commit()
616 self.assertEqual(1, len(pc.queue.iterate())) 616 self.assertEqual(1, len(pc.queue.iterate()))
617 # Pop the LGTM. 617 # Pop the LGTM.
618 pc.queue.iterate()[0].messages.pop(1) 618 pc.queue.iterate()[0].messages.pop(1)
619 pc.process_new_pending_commit() 619 pc.process_new_pending_commit()
620 self.assertEqual(0, len(pc.queue.iterate())) 620 self.assertEqual(0, len(pc.queue.iterate()))
621 pc.update_status() 621 pc.update_status()
622 self.assertEqual(0, len(pc.queue.iterate())) 622 self.assertEqual(0, len(pc.queue.iterate()))
623 self.context.rietveld.check_calls( 623 self.context.rietveld.check_calls(
624 [ "set_flag(%d, 1, 'commit', 'False')" % issue, 624 [ "set_flag(%d, 1, 'commit', False)" % issue,
625 "add_comment(%d, %r)" % (issue, reviewer_lgtm.LgtmStatus.NO_LGTM)]) 625 "add_comment(%d, %r)" % (issue, reviewer_lgtm.LgtmStatus.NO_LGTM)])
626 self.context.status.check_names(['abort']) 626 self.context.status.check_names(['abort'])
627 627
628 def testVerifyDefaultMockPlusLGTM(self): 628 def testVerifyDefaultMockPlusLGTM(self):
629 # Verify mock expectation with a single approval message. 629 # Verify mock expectation with a single approval message.
630 issue = 31337 630 issue = 31337
631 pc = self._get_pc_reviewer() 631 pc = self._get_pc_reviewer()
632 self._approve() 632 self._approve()
633 self.assertEqual(0, len(pc.queue.iterate())) 633 self.assertEqual(0, len(pc.queue.iterate()))
634 pc.look_for_new_pending_commit() 634 pc.look_for_new_pending_commit()
(...skipping 19 matching lines...) Expand all
654 self._approve() 654 self._approve()
655 pc.look_for_new_pending_commit() 655 pc.look_for_new_pending_commit()
656 pc.process_new_pending_commit() 656 pc.process_new_pending_commit()
657 pc.update_status() 657 pc.update_status()
658 # A new reviewer prevents the commit. 658 # A new reviewer prevents the commit.
659 i = self.context.rietveld.issues[issue] 659 i = self.context.rietveld.issues[issue]
660 i['reviewers'] = i['reviewers'] + ['annoying@dude.org'] 660 i['reviewers'] = i['reviewers'] + ['annoying@dude.org']
661 pc.scan_results() 661 pc.scan_results()
662 self.context.rietveld.check_calls( 662 self.context.rietveld.check_calls(
663 [ _try_comment(), 663 [ _try_comment(),
664 "set_flag(%d, 1, 'commit', 'False')" % issue, 664 "set_flag(%d, 1, 'commit', False)" % issue,
665 ('add_comment(%d, "List of reviewers changed. annoying@dude.org ' 665 ('add_comment(%d, "List of reviewers changed. annoying@dude.org '
666 'did a drive-by without LGTM\'ing!")') % issue]) 666 'did a drive-by without LGTM\'ing!")') % issue])
667 self.context.status.check_names(['initial', 'abort']) 667 self.context.status.check_names(['initial', 'abort'])
668 668
669 def testDriveByLGTM(self): 669 def testDriveByLGTM(self):
670 issue = 31337 670 issue = 31337
671 pc = self._get_pc_reviewer() 671 pc = self._get_pc_reviewer()
672 self._approve() 672 self._approve()
673 pc.look_for_new_pending_commit() 673 pc.look_for_new_pending_commit()
674 pc.process_new_pending_commit() 674 pc.process_new_pending_commit()
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 self.context.checkout.check_calls( 720 self.context.checkout.check_calls(
721 self._prepare_apply_commit(0, issue)) 721 self._prepare_apply_commit(0, issue))
722 722
723 723
724 if __name__ == '__main__': 724 if __name__ == '__main__':
725 logging.basicConfig( 725 logging.basicConfig(
726 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 726 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
727 min(sys.argv.count('-v'), 3)], 727 min(sys.argv.count('-v'), 3)],
728 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') 728 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s')
729 unittest.main() 729 unittest.main()
OLDNEW
« no previous file with comments | « commit-queue/pending_manager.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698