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