| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 'prepare(None)', # Will sync to HEAD/124. | 99 'prepare(None)', # Will sync to HEAD/124. |
| 100 'apply_patch(%r)' % (self.context.rietveld.patchsets[1],), | 100 'apply_patch(%r)' % (self.context.rietveld.patchsets[1],), |
| 101 ( | 101 ( |
| 102 "commit(u'foo\\n\\n" | 102 "commit(u'foo\\n\\n" |
| 103 "Review URL: http://nowhere/%d', " | 103 "Review URL: http://nowhere/%d', " |
| 104 "u'author@example.com')") % issue]) | 104 "u'author@example.com')") % issue]) |
| 105 self.context.rietveld.check_calls( | 105 self.context.rietveld.check_calls( |
| 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 "set_flag(%d, 1, 'commit', False)" % issue, |
| 109 "add_comment(%d, 'Change committed as 125')" % issue]) | 110 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 110 else: | 111 else: |
| 111 self.context.checkout.check_calls( | 112 self.context.checkout.check_calls( |
| 112 [ 'prepare(None)', | 113 [ 'prepare(None)', |
| 113 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],)]) | 114 'apply_patch(%r)' % (self.context.rietveld.patchsets[0],)]) |
| 114 self.context.rietveld.check_calls( | 115 self.context.rietveld.check_calls( |
| 115 [ _try_comment(), | 116 [ _try_comment(), |
| 116 "set_flag(%d, 1, 'commit', False)" % issue, | 117 "set_flag(%d, 1, 'commit', False)" % issue, |
| 117 "add_comment(%d, %r)" % (issue, fake.failed_message())]) | 118 "add_comment(%d, %r)" % (issue, fake.failed_message())]) |
| 118 else: | 119 else: |
| 119 if success: | 120 if success: |
| 120 self.context.checkout.check_calls( | 121 self.context.checkout.check_calls( |
| 121 self._prepare_apply_commit(0, issue)) | 122 self._prepare_apply_commit(0, issue)) |
| 122 self.context.rietveld.check_calls( | 123 self.context.rietveld.check_calls( |
| 123 [ _try_comment(), | 124 [ _try_comment(), |
| 124 'close_issue(%d)' % issue, | 125 'close_issue(%d)' % issue, |
| 125 "update_description(%d, u'foo')" % issue, | 126 "update_description(%d, u'foo')" % issue, |
| 127 "set_flag(%d, 1, 'commit', False)" % issue, |
| 126 "add_comment(%d, 'Change committed as 125')" % issue]) | 128 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 127 else: | 129 else: |
| 128 # checkout is never touched in that case. | 130 # checkout is never touched in that case. |
| 129 self.context.checkout.check_calls([]) | 131 self.context.checkout.check_calls([]) |
| 130 if defered: | 132 if defered: |
| 131 self.context.rietveld.check_calls( | 133 self.context.rietveld.check_calls( |
| 132 [ _try_comment(), | 134 [ _try_comment(), |
| 133 "set_flag(%d, 1, 'commit', False)" % issue, | 135 "set_flag(%d, 1, 'commit', False)" % issue, |
| 134 "add_comment(%d, %r)" % (issue, fake.failed_message())]) | 136 "add_comment(%d, %r)" % (issue, fake.failed_message())]) |
| 135 else: | 137 else: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if result == base.FAILED: | 205 if result == base.FAILED: |
| 204 self.assertEqual([], pc.queue.iterate()) | 206 self.assertEqual([], pc.queue.iterate()) |
| 205 else: | 207 else: |
| 206 commit = pc.queue.get(issue) | 208 commit = pc.queue.get(issue) |
| 207 self.assertEqual(commit.verifications['fake'].get_state(), result) | 209 self.assertEqual(commit.verifications['fake'].get_state(), result) |
| 208 self.assertEqual('', commit.relpath) | 210 self.assertEqual('', commit.relpath) |
| 209 self.assertEqual(len(commit.verifications), 1) | 211 self.assertEqual(len(commit.verifications), 1) |
| 210 self._check_standard_verification(pc, result == base.SUCCEEDED, False) | 212 self._check_standard_verification(pc, result == base.SUCCEEDED, False) |
| 211 | 213 |
| 212 if result == base.SUCCEEDED: | 214 if result == base.SUCCEEDED: |
| 213 self.context.status.check_names(['initial', 'why not', 'commit']) | 215 self.context.status.check_names( |
| 216 ['initial', 'why not', 'commit', 'abort']) |
| 214 elif send_initial_packet: | 217 elif send_initial_packet: |
| 215 self.context.status.check_names(['initial', 'abort']) | 218 self.context.status.check_names(['initial', 'abort']) |
| 216 else: | 219 else: |
| 217 # Only happens when there is no verifier that requires a patch. | 220 # Only happens when there is no verifier that requires a patch. |
| 218 self.context.status.check_names(['abort']) | 221 self.context.status.check_names(['abort']) |
| 219 | 222 |
| 220 def testNoPatchVerification(self): | 223 def testNoPatchVerification(self): |
| 221 pc = self._get_pc([fake.FakeVerifier(base.SUCCEEDED)], []) | 224 pc = self._get_pc([fake.FakeVerifier(base.SUCCEEDED)], []) |
| 222 self._check_1(pc, base.SUCCEEDED) | 225 self._check_1(pc, base.SUCCEEDED) |
| 223 | 226 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 self.assertEqual(commit.verifications['fake'].get_state(), base.PROCESSING) | 285 self.assertEqual(commit.verifications['fake'].get_state(), base.PROCESSING) |
| 283 self.assertEqual(len(commit.verifications), 1) | 286 self.assertEqual(len(commit.verifications), 1) |
| 284 pc.update_status() | 287 pc.update_status() |
| 285 commit = pc.queue.get(issue) | 288 commit = pc.queue.get(issue) |
| 286 self.assertEqual('', commit.relpath) | 289 self.assertEqual('', commit.relpath) |
| 287 self.assertEqual(commit.verifications['fake'].get_state(), result) | 290 self.assertEqual(commit.verifications['fake'].get_state(), result) |
| 288 self.assertEqual(len(commit.verifications), 1) | 291 self.assertEqual(len(commit.verifications), 1) |
| 289 self._check_standard_verification(pc, result == base.SUCCEEDED, True) | 292 self._check_standard_verification(pc, result == base.SUCCEEDED, True) |
| 290 if result == base.SUCCEEDED: | 293 if result == base.SUCCEEDED: |
| 291 self.context.status.check_names(['initial', 'why not', 'why not', | 294 self.context.status.check_names(['initial', 'why not', 'why not', |
| 292 'why not', 'commit']) | 295 'why not', 'commit', 'abort']) |
| 293 else: | 296 else: |
| 294 self.context.status.check_names(['initial', 'why not', 'why not', | 297 self.context.status.check_names(['initial', 'why not', 'why not', |
| 295 'abort']) | 298 'abort']) |
| 296 | 299 |
| 297 def testDeferNoPatchVerification(self): | 300 def testDeferNoPatchVerification(self): |
| 298 pc = self._get_pc([fake.DeferredFakeVerifier(base.SUCCEEDED, 0)], []) | 301 pc = self._get_pc([fake.DeferredFakeVerifier(base.SUCCEEDED, 0)], []) |
| 299 self._check_defer_1(pc, base.SUCCEEDED) | 302 self._check_defer_1(pc, base.SUCCEEDED) |
| 300 | 303 |
| 301 def testDeferPatchVerification(self): | 304 def testDeferPatchVerification(self): |
| 302 pc = self._get_pc([], [fake.DeferredFakeVerifier(base.SUCCEEDED, 0)]) | 305 pc = self._get_pc([], [fake.DeferredFakeVerifier(base.SUCCEEDED, 0)]) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 else: | 352 else: |
| 350 commit = pc.queue.get(issue) | 353 commit = pc.queue.get(issue) |
| 351 self.assertEqual(commit.verifications['fake1'].get_state(), f1) | 354 self.assertEqual(commit.verifications['fake1'].get_state(), f1) |
| 352 self.assertEqual(commit.verifications['fake2'].get_state(), f2) | 355 self.assertEqual(commit.verifications['fake2'].get_state(), f2) |
| 353 self.assertEqual(commit.verifications['fake3'].get_state(), f3) | 356 self.assertEqual(commit.verifications['fake3'].get_state(), f3) |
| 354 self.assertEqual(commit.verifications['fake4'].get_state(), f4) | 357 self.assertEqual(commit.verifications['fake4'].get_state(), f4) |
| 355 self.assertEqual(len(commit.verifications), nb) | 358 self.assertEqual(len(commit.verifications), nb) |
| 356 self._check_standard_verification( | 359 self._check_standard_verification( |
| 357 pc, all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)), False) | 360 pc, all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)), False) |
| 358 if all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)): | 361 if all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)): |
| 359 self.context.status.check_names(['initial', 'why not', 'commit']) | 362 self.context.status.check_names(['initial', 'why not', 'commit', 'abort']) |
| 360 else: | 363 else: |
| 361 self.context.status.check_names(['initial', 'abort']) | 364 self.context.status.check_names(['initial', 'abort']) |
| 362 | 365 |
| 363 def test4thVerificationFail(self): | 366 def test4thVerificationFail(self): |
| 364 self._check_4(base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.FAILED) | 367 self._check_4(base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.FAILED) |
| 365 | 368 |
| 366 def test4Verification(self): | 369 def test4Verification(self): |
| 367 self._check_4( | 370 self._check_4( |
| 368 base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED) | 371 base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED) |
| 369 | 372 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 400 pc.update_status() | 403 pc.update_status() |
| 401 self.assertEqual(commit.verifications['fake1'].get_state(), f1) | 404 self.assertEqual(commit.verifications['fake1'].get_state(), f1) |
| 402 self.assertEqual(commit.verifications['fake2'].get_state(), f2) | 405 self.assertEqual(commit.verifications['fake2'].get_state(), f2) |
| 403 self.assertEqual(commit.verifications['fake3'].get_state(), f3) | 406 self.assertEqual(commit.verifications['fake3'].get_state(), f3) |
| 404 self.assertEqual(commit.verifications['fake4'].get_state(), f4) | 407 self.assertEqual(commit.verifications['fake4'].get_state(), f4) |
| 405 self.assertEqual('', commit.relpath) | 408 self.assertEqual('', commit.relpath) |
| 406 self._check_standard_verification( | 409 self._check_standard_verification( |
| 407 pc, all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)), False) | 410 pc, all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)), False) |
| 408 if all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)): | 411 if all(x == base.SUCCEEDED for x in (f1, f2, f3, f4)): |
| 409 self.context.status.check_names(['initial', 'why not', 'why not', | 412 self.context.status.check_names(['initial', 'why not', 'why not', |
| 410 'why not', 'commit']) | 413 'why not', 'commit', 'abort']) |
| 411 else: | 414 else: |
| 412 self.context.status.check_names(['initial', 'why not', 'why not', | 415 self.context.status.check_names(['initial', 'why not', 'why not', |
| 413 'abort']) | 416 'abort']) |
| 414 | 417 |
| 415 def testDefer4thVerificationFail(self): | 418 def testDefer4thVerificationFail(self): |
| 416 self._check_defer_4( | 419 self._check_defer_4( |
| 417 base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.FAILED) | 420 base.SUCCEEDED, base.SUCCEEDED, base.SUCCEEDED, base.FAILED) |
| 418 | 421 |
| 419 def testDefer4Verification(self): | 422 def testDefer4Verification(self): |
| 420 self._check_defer_4( | 423 self._check_defer_4( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 442 pc.update_status() | 445 pc.update_status() |
| 443 self.context.checkout.check_calls([]) | 446 self.context.checkout.check_calls([]) |
| 444 pc.scan_results() | 447 pc.scan_results() |
| 445 self.context.checkout.check_calls( | 448 self.context.checkout.check_calls( |
| 446 # Will sync to HEAD, 124. | 449 # Will sync to HEAD, 124. |
| 447 self._prepare_apply_commit(1, issue)) | 450 self._prepare_apply_commit(1, issue)) |
| 448 self.context.rietveld.check_calls( | 451 self.context.rietveld.check_calls( |
| 449 [ _try_comment(), | 452 [ _try_comment(), |
| 450 'close_issue(%d)' % issue, | 453 'close_issue(%d)' % issue, |
| 451 "update_description(%d, u'foo')" % issue, | 454 "update_description(%d, u'foo')" % issue, |
| 455 "set_flag(%d, 1, 'commit', False)" % issue, |
| 452 "add_comment(%d, 'Change committed as 125')" % issue]) | 456 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 453 self.context.status.check_names(['initial', 'why not', 'commit']) | 457 self.context.status.check_names(['initial', 'why not', 'commit', 'abort']) |
| 454 | 458 |
| 455 def testCommitBurst(self): | 459 def testCommitBurst(self): |
| 456 issue = 31337 | 460 issue = 31337 |
| 457 pc = self._get_pc([fake.FakeVerifier(base.SUCCEEDED)], []) | 461 pc = self._get_pc([fake.FakeVerifier(base.SUCCEEDED)], []) |
| 458 self.assertEqual(4, pc.MAX_COMMIT_BURST) | 462 self.assertEqual(4, pc.MAX_COMMIT_BURST) |
| 459 timestamp = [1] | 463 timestamp = [1] |
| 460 self.mock(time, 'time', lambda: timestamp[-1]) | 464 self.mock(time, 'time', lambda: timestamp[-1]) |
| 461 for i in range(pc.MAX_COMMIT_BURST + 2): | 465 for i in range(pc.MAX_COMMIT_BURST + 2): |
| 462 self.context.rietveld.issues[i] = ( | 466 self.context.rietveld.issues[i] = ( |
| 463 self.context.rietveld.issues[issue].copy()) | 467 self.context.rietveld.issues[issue].copy()) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 475 self.context.rietveld.check_calls( | 479 self.context.rietveld.check_calls( |
| 476 [ _try_comment(0), | 480 [ _try_comment(0), |
| 477 _try_comment(1), | 481 _try_comment(1), |
| 478 _try_comment(2), | 482 _try_comment(2), |
| 479 _try_comment(3), | 483 _try_comment(3), |
| 480 _try_comment(4), | 484 _try_comment(4), |
| 481 _try_comment(5), | 485 _try_comment(5), |
| 482 _try_comment(), | 486 _try_comment(), |
| 483 'close_issue(0)', | 487 'close_issue(0)', |
| 484 "update_description(0, u'foo')", | 488 "update_description(0, u'foo')", |
| 489 "set_flag(0, 1, 'commit', False)", |
| 485 "add_comment(0, 'Change committed as 125')", | 490 "add_comment(0, 'Change committed as 125')", |
| 486 'close_issue(1)', | 491 'close_issue(1)', |
| 487 "update_description(1, u'foo')", | 492 "update_description(1, u'foo')", |
| 493 "set_flag(1, 1, 'commit', False)", |
| 488 "add_comment(1, 'Change committed as 125')", | 494 "add_comment(1, 'Change committed as 125')", |
| 489 'close_issue(2)', | 495 'close_issue(2)', |
| 490 "update_description(2, u'foo')", | 496 "update_description(2, u'foo')", |
| 497 "set_flag(2, 1, 'commit', False)", |
| 491 "add_comment(2, 'Change committed as 125')", | 498 "add_comment(2, 'Change committed as 125')", |
| 492 'close_issue(3)', | 499 'close_issue(3)', |
| 493 "update_description(3, u'foo')", | 500 "update_description(3, u'foo')", |
| 501 "set_flag(3, 1, 'commit', False)", |
| 494 "add_comment(3, 'Change committed as 125')", | 502 "add_comment(3, 'Change committed as 125')", |
| 495 ]) | 503 ]) |
| 496 self.assertEqual(3, len(pc.queue.iterate())) | 504 self.assertEqual(3, len(pc.queue.iterate())) |
| 497 total = pc.MAX_COMMIT_BURST + 3 | 505 total = pc.MAX_COMMIT_BURST + 3 |
| 498 self.context.status.check_names(['initial'] * total + | 506 self.context.status.check_names(['initial'] * total + |
| 499 (['why not', 'commit'] * | 507 (['why not', 'commit', 'abort'] * |
| 500 pc.MAX_COMMIT_BURST) + | 508 pc.MAX_COMMIT_BURST) + |
| 501 ['why not'] * 3) | 509 ['why not'] * 3) |
| 502 | 510 |
| 503 # Dry run. | 511 # Dry run. |
| 504 pc.scan_results() | 512 pc.scan_results() |
| 505 self.context.checkout.check_calls([]) | 513 self.context.checkout.check_calls([]) |
| 506 self.context.rietveld.check_calls([]) | 514 self.context.rietveld.check_calls([]) |
| 507 self.context.status.check_names(['why not'] * 3) | 515 self.context.status.check_names(['why not'] * 3) |
| 508 | 516 |
| 509 # Remove one item from the burst. | 517 # Remove one item from the burst. |
| 510 pc.recent_commit_timestamps.pop() | 518 pc.recent_commit_timestamps.pop() |
| 511 pc.scan_results() | 519 pc.scan_results() |
| 512 next_item = pc.MAX_COMMIT_BURST | 520 next_item = pc.MAX_COMMIT_BURST |
| 513 self.context.checkout.check_calls( | 521 self.context.checkout.check_calls( |
| 514 self._prepare_apply_commit(next_item, next_item)) | 522 self._prepare_apply_commit(next_item, next_item)) |
| 515 self.context.rietveld.check_calls( | 523 self.context.rietveld.check_calls( |
| 516 [ 'close_issue(%d)' % next_item, | 524 [ 'close_issue(%d)' % next_item, |
| 517 "update_description(%d, u'foo')" % next_item, | 525 "update_description(%d, u'foo')" % next_item, |
| 526 "set_flag(%d, 1, 'commit', False)" % next_item, |
| 518 "add_comment(%d, 'Change committed as 125')" % next_item, | 527 "add_comment(%d, 'Change committed as 125')" % next_item, |
| 519 ]) | 528 ]) |
| 520 self.context.status.check_names(['why not', 'commit'] + ['why not'] * 2) | 529 self.context.status.check_names(['why not', 'commit', 'abort'] + |
| 530 ['why not'] * 2) |
| 521 # After a delay, must flush the queue. | 531 # After a delay, must flush the queue. |
| 522 timestamp.append(timestamp[-1] + pc.COMMIT_BURST_DELAY + 1) | 532 timestamp.append(timestamp[-1] + pc.COMMIT_BURST_DELAY + 1) |
| 523 pc.scan_results() | 533 pc.scan_results() |
| 524 self.context.checkout.check_calls( | 534 self.context.checkout.check_calls( |
| 525 self._prepare_apply_commit(next_item + 1, next_item + 1) + | 535 self._prepare_apply_commit(next_item + 1, next_item + 1) + |
| 526 self._prepare_apply_commit(next_item + 2, issue)) | 536 self._prepare_apply_commit(next_item + 2, issue)) |
| 527 self.context.rietveld.check_calls( | 537 self.context.rietveld.check_calls( |
| 528 [ 'close_issue(%d)' % (next_item + 1), | 538 [ 'close_issue(%d)' % (next_item + 1), |
| 529 "update_description(%d, u'foo')" % (next_item + 1), | 539 "update_description(%d, u'foo')" % (next_item + 1), |
| 540 "set_flag(%d, 1, 'commit', False)" % (next_item + 1), |
| 530 "add_comment(%d, 'Change committed as 125')" % (next_item + 1), | 541 "add_comment(%d, 'Change committed as 125')" % (next_item + 1), |
| 531 'close_issue(%d)' % issue, | 542 'close_issue(%d)' % issue, |
| 532 "update_description(%d, u'foo')" % issue, | 543 "update_description(%d, u'foo')" % issue, |
| 544 "set_flag(%d, 1, 'commit', False)" % issue, |
| 533 "add_comment(%d, 'Change committed as 125')" % issue]) | 545 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 534 self.context.status.check_names(['why not', 'commit'] * 2) | 546 self.context.status.check_names(['why not', 'commit', 'abort'] * 2) |
| 535 | 547 |
| 536 def testIgnored(self): | 548 def testIgnored(self): |
| 537 issue = 31337 | 549 issue = 31337 |
| 538 verifiers = [ | 550 verifiers = [ |
| 539 project_base.ProjectBaseUrlVerifier( | 551 project_base.ProjectBaseUrlVerifier( |
| 540 [r'^%s(.*)$' % re.escape(r'http://example.com/')]), | 552 [r'^%s(.*)$' % re.escape(r'http://example.com/')]), |
| 541 ] | 553 ] |
| 542 pc = self._get_pc(verifiers, []) | 554 pc = self._get_pc(verifiers, []) |
| 543 pc.context.rietveld.issues[issue]['base_url'] = 'http://unrelated.com/sub' | 555 pc.context.rietveld.issues[issue]['base_url'] = 'http://unrelated.com/sub' |
| 544 pc.look_for_new_pending_commit() | 556 pc.look_for_new_pending_commit() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 559 pc = self._get_pc(verifiers, []) | 571 pc = self._get_pc(verifiers, []) |
| 560 pc.context.rietveld.issues[issue]['base_url'] = 'http://example.com/' | 572 pc.context.rietveld.issues[issue]['base_url'] = 'http://example.com/' |
| 561 pc.look_for_new_pending_commit() | 573 pc.look_for_new_pending_commit() |
| 562 pc.process_new_pending_commit() | 574 pc.process_new_pending_commit() |
| 563 pc.update_status() | 575 pc.update_status() |
| 564 pc.scan_results() | 576 pc.scan_results() |
| 565 self.context.rietveld.check_calls( | 577 self.context.rietveld.check_calls( |
| 566 [ _try_comment(), | 578 [ _try_comment(), |
| 567 'close_issue(%d)' % issue, | 579 'close_issue(%d)' % issue, |
| 568 "update_description(%d, u'foo')" % issue, | 580 "update_description(%d, u'foo')" % issue, |
| 581 "set_flag(%d, 1, 'commit', False)" % issue, |
| 569 "add_comment(%d, 'Change committed as 125')" % issue]) | 582 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 570 self.context.status.check_names(['initial', 'why not', 'commit']) | 583 self.context.status.check_names(['initial', 'why not', 'commit', 'abort']) |
| 571 self.context.checkout.check_calls( | 584 self.context.checkout.check_calls( |
| 572 self._prepare_apply_commit(0, issue, server_hooks_missing=True)) | 585 self._prepare_apply_commit(0, issue, server_hooks_missing=True)) |
| 573 | 586 |
| 574 def testDisappeared(self): | 587 def testDisappeared(self): |
| 575 issue = 31337 | 588 issue = 31337 |
| 576 verifiers = [ | 589 verifiers = [ |
| 577 project_base.ProjectBaseUrlVerifier( | 590 project_base.ProjectBaseUrlVerifier( |
| 578 [r'^%s(.*)$' % re.escape(r'http://example.com/')]), | 591 [r'^%s(.*)$' % re.escape(r'http://example.com/')]), |
| 579 ] | 592 ] |
| 580 pc = self._get_pc(verifiers, []) | 593 pc = self._get_pc(verifiers, []) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 pc.process_new_pending_commit() | 654 pc.process_new_pending_commit() |
| 642 self.assertEqual(1, len(pc.queue.iterate())) | 655 self.assertEqual(1, len(pc.queue.iterate())) |
| 643 pc.update_status() | 656 pc.update_status() |
| 644 self.assertEqual(1, len(pc.queue.iterate())) | 657 self.assertEqual(1, len(pc.queue.iterate())) |
| 645 pc.scan_results() | 658 pc.scan_results() |
| 646 self.assertEqual(0, len(pc.queue.iterate())) | 659 self.assertEqual(0, len(pc.queue.iterate())) |
| 647 self.context.rietveld.check_calls( | 660 self.context.rietveld.check_calls( |
| 648 [ _try_comment(), | 661 [ _try_comment(), |
| 649 'close_issue(%d)' % issue, | 662 'close_issue(%d)' % issue, |
| 650 "update_description(%d, u'foo')" % issue, | 663 "update_description(%d, u'foo')" % issue, |
| 664 "set_flag(%d, 1, 'commit', False)" % issue, |
| 651 "add_comment(%d, 'Change committed as 125')" % issue]) | 665 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 652 self.context.status.check_names(['initial', 'why not', 'commit']) | 666 self.context.status.check_names(['initial', 'why not', 'commit', 'abort']) |
| 653 self.context.checkout.check_calls( | 667 self.context.checkout.check_calls( |
| 654 self._prepare_apply_commit(0, issue)) | 668 self._prepare_apply_commit(0, issue)) |
| 655 | 669 |
| 656 def testDriveBy(self): | 670 def testDriveBy(self): |
| 657 issue = 31337 | 671 issue = 31337 |
| 658 pc = self._get_pc_reviewer() | 672 pc = self._get_pc_reviewer() |
| 659 self._approve() | 673 self._approve() |
| 660 pc.look_for_new_pending_commit() | 674 pc.look_for_new_pending_commit() |
| 661 pc.process_new_pending_commit() | 675 pc.process_new_pending_commit() |
| 662 pc.update_status() | 676 pc.update_status() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 681 # He's nice, he left a LGTM. | 695 # He's nice, he left a LGTM. |
| 682 i = self.context.rietveld.issues[issue] | 696 i = self.context.rietveld.issues[issue] |
| 683 i['reviewers'] = i['reviewers'] + ['nice@dude.org'] | 697 i['reviewers'] = i['reviewers'] + ['nice@dude.org'] |
| 684 self._approve('nice@dude.org') | 698 self._approve('nice@dude.org') |
| 685 pc.scan_results() | 699 pc.scan_results() |
| 686 self.assertEqual(0, len(pc.queue.iterate())) | 700 self.assertEqual(0, len(pc.queue.iterate())) |
| 687 self.context.rietveld.check_calls( | 701 self.context.rietveld.check_calls( |
| 688 [ _try_comment(), | 702 [ _try_comment(), |
| 689 'close_issue(%d)' % issue, | 703 'close_issue(%d)' % issue, |
| 690 "update_description(%d, u'foo')" % issue, | 704 "update_description(%d, u'foo')" % issue, |
| 705 "set_flag(%d, 1, 'commit', False)" % issue, |
| 691 "add_comment(%d, 'Change committed as 125')" % issue]) | 706 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 692 self.context.status.check_names(['initial', 'why not', 'commit']) | 707 self.context.status.check_names(['initial', 'why not', 'commit', 'abort']) |
| 693 self.context.checkout.check_calls( | 708 self.context.checkout.check_calls( |
| 694 self._prepare_apply_commit(0, issue)) | 709 self._prepare_apply_commit(0, issue)) |
| 695 | 710 |
| 696 def testWhyNotUpdates(self): | 711 def testWhyNotUpdates(self): |
| 697 issue = 31337 | 712 issue = 31337 |
| 698 fake1_change = 1 | 713 fake1_change = 1 |
| 699 fake1 = fake.DeferredFakeVerifier(base.SUCCEEDED, fake1_change) | 714 fake1 = fake.DeferredFakeVerifier(base.SUCCEEDED, fake1_change) |
| 700 fake1.name = 'fake1' | 715 fake1.name = 'fake1' |
| 701 | 716 |
| 702 fake2_change = 3 | 717 fake2_change = 3 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 713 expected = ['why not'] if fake1_change == i or fake2_change == i else [] | 728 expected = ['why not'] if fake1_change == i or fake2_change == i else [] |
| 714 pc.update_status() | 729 pc.update_status() |
| 715 self.context.status.check_names(expected) | 730 self.context.status.check_names(expected) |
| 716 | 731 |
| 717 pc.scan_results() | 732 pc.scan_results() |
| 718 | 733 |
| 719 self.context.rietveld.check_calls( | 734 self.context.rietveld.check_calls( |
| 720 [_try_comment(), | 735 [_try_comment(), |
| 721 'close_issue(%d)' % issue, | 736 'close_issue(%d)' % issue, |
| 722 "update_description(%d, u'foo')" % issue, | 737 "update_description(%d, u'foo')" % issue, |
| 738 "set_flag(%d, 1, 'commit', False)" % issue, |
| 723 "add_comment(%d, 'Change committed as 125')" % issue]) | 739 "add_comment(%d, 'Change committed as 125')" % issue]) |
| 724 self.context.status.check_names(['why not', 'commit']) | 740 self.context.status.check_names(['why not', 'commit', 'abort']) |
| 725 self.context.checkout.check_calls( | 741 self.context.checkout.check_calls( |
| 726 self._prepare_apply_commit(0, issue)) | 742 self._prepare_apply_commit(0, issue)) |
| 727 | 743 |
| 728 | 744 |
| 729 if __name__ == '__main__': | 745 if __name__ == '__main__': |
| 730 logging.basicConfig( | 746 logging.basicConfig( |
| 731 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 747 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
| 732 min(sys.argv.count('-v'), 3)], | 748 min(sys.argv.count('-v'), 3)], |
| 733 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') | 749 format='%(levelname)5s %(module)15s(%(lineno)3d): %(message)s') |
| 734 unittest.main() | 750 unittest.main() |
| OLD | NEW |