OLD | NEW |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 commit_message = ( | 158 commit_message = ( |
159 "commit(u'foo%s\\n\\n" | 159 "commit(u'foo%s\\n\\n" |
160 "Review URL: http://nowhere/%d', " | 160 "Review URL: http://nowhere/%d', " |
161 "u'author@example.com')") % (author_and_reviewer, issue) | 161 "u'author@example.com')") % (author_and_reviewer, issue) |
162 seq.append(commit_message) | 162 seq.append(commit_message) |
163 | 163 |
164 return seq | 164 return seq |
165 | 165 |
166 def testNoVerification(self): | 166 def testNoVerification(self): |
167 try: | 167 try: |
168 # Need at least one verification. | |
169 self._get_pc([], []) | 168 self._get_pc([], []) |
170 self.fail() | 169 except ValueError: |
171 except AssertionError: | |
172 pass | 170 pass |
| 171 else: |
| 172 self.fail(msg='A PendingManager must require at least one verifier.') |
| 173 |
173 try: | 174 try: |
174 # Cannot have the same verifier two times. | 175 # Cannot have the same verifier two times. |
175 self._get_pc( | 176 self._get_pc( |
176 [fake.FakeVerifier(base.SUCCEEDED)], | 177 [fake.FakeVerifier(base.SUCCEEDED)], |
177 [fake.FakeVerifier(base.SUCCEEDED)]) | 178 [fake.FakeVerifier(base.SUCCEEDED)]) |
178 self.fail() | |
179 except AssertionError: | 179 except AssertionError: |
180 pass | 180 pass |
| 181 else: |
| 182 self.fail(msg='A PendingManager should not accept the same verifier' |
| 183 ' two times.') |
181 | 184 |
182 def _check_1(self, pc, result): | 185 def _check_1(self, pc, result): |
183 issue = 31337 | 186 issue = 31337 |
184 # 'initial' won't be sent if the pre-patch verification fails, this is to | 187 # 'initial' won't be sent if the pre-patch verification fails, this is to |
185 # not add noise for ignored CLs. | 188 # not add noise for ignored CLs. |
186 send_initial_packet = (result == base.SUCCEEDED or pc.verifiers) | 189 send_initial_packet = (result == base.SUCCEEDED or pc.verifiers) |
187 self.assertEqual(len(pc.queue.iterate()), 0) | 190 self.assertEqual(len(pc.queue.iterate()), 0) |
188 pc.look_for_new_pending_commit() | 191 pc.look_for_new_pending_commit() |
189 self.assertEqual(len(pc.queue.iterate()), 1) | 192 self.assertEqual(len(pc.queue.iterate()), 1) |
190 commit = pc.queue.get(issue) | 193 commit = pc.queue.get(issue) |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 self.context.checkout.check_calls( | 723 self.context.checkout.check_calls( |
721 self._prepare_apply_commit(0, issue)) | 724 self._prepare_apply_commit(0, issue)) |
722 | 725 |
723 | 726 |
724 if __name__ == '__main__': | 727 if __name__ == '__main__': |
725 logging.basicConfig( | 728 logging.basicConfig( |
726 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 729 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
727 min(sys.argv.count('-v'), 3)], | 730 min(sys.argv.count('-v'), 3)], |
728 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') | 731 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') |
729 unittest.main() | 732 unittest.main() |
OLD | NEW |