~fgimenez/+junk/jenkins-launchpad-plugin

« back to all changes in this revision

Viewing changes to tests/test_autoland.py

  • Committer: Tarmac
  • Author(s): mrazik
  • Date: 2013-05-17 15:36:49 UTC
  • mfrom: (106.1.3 locking-fix)
  • Revision ID: tarmac-20130517153649-x58w25z4i9w7kuxw
This fixed stale locks when an error happens during autolanding (e.g. merge error). It also unlocks the merge proposal earlier to decrease the chance of a stale lock.

Approved by Francis Ginther, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
347
347
        super(TestAutolandMergeAndCommitMergeConflict, self).tearDown()
348
348
        self.branch_patch.stop()
349
349
 
350
 
    def test_merge_and_commit_merge_conflict(self):
 
350
    @patch('jlp.commands.autoland.MergeProposalReview')
 
351
    def test_merge_and_commit_merge_conflict(self, MergeProposalReview):
351
352
        sys_argv = ['autoland.py', '-r', 'PASSED',
352
353
                    '-v', '123', '-m', 'url']
 
354
        review = MagicMock()
 
355
        MergeProposalReview.return_value = review
353
356
        with patch('sys.argv', sys_argv):
354
357
            self.assertTrue(autoland.autoland() == 1)
 
358
            self.assertEqual(review.unlock.call_count, 1)
355
359
 
356
360
 
357
361
class TestAutolandMergeAndCommitPushFailed(TestAutoland):
370
374
        super(TestAutolandMergeAndCommitPushFailed, self).tearDown()
371
375
        self.branch_patch.stop()
372
376
 
373
 
    def test_merge_and_commit_push_error(self):
 
377
    @patch('jlp.commands.autoland.MergeProposalReview')
 
378
    def test_merge_and_commit_push_error(self, MergeProposalReview):
374
379
        sys_argv = ['autoland.py', '-r', 'PASSED',
375
380
                    '-v', '123', '-m', 'url']
 
381
        review = MagicMock()
 
382
        MergeProposalReview.return_value = review
376
383
        with patch('sys.argv', sys_argv):
377
384
            self.assertTrue(autoland.autoland() == 1)
 
385
            self.assertEqual(review.unlock.call_count, 1)
378
386
 
379
387
 
380
388
class TestAutolandMergeAndCommitLockFailed(TestAutoland):
393
401
        super(TestAutolandMergeAndCommitLockFailed, self).tearDown()
394
402
        self.branch_patch.stop()
395
403
 
396
 
    def test_merge_and_commit_lock_failed(self):
 
404
    @patch('jlp.commands.autoland.MergeProposalReview')
 
405
    def test_merge_and_commit_lock_failed(self, MergeProposalReview):
397
406
        sys_argv = ['autoland.py', '-r', 'PASSED',
398
407
                    '-v', '123', '-m', 'url']
 
408
        review = MagicMock()
 
409
        MergeProposalReview.return_value = review
399
410
        with patch('sys.argv', sys_argv):
400
411
            self.assertTrue(autoland.autoland() == 1)
 
412
            self.assertEqual(review.unlock.call_count, 1)
401
413
 
402
414
 
403
415
class TestAutolandMergeAndCommitUnapprovedChange(TestAutoland):