def test_succeeds_first_time(self, unused_time_sleep): api, mocklab = self.api, self.mocklab with patch('marge.job.update_from_target_branch_and_push', side_effect=mocklab.push_updated): job = self.make_job(marge.job.MergeJobOptions.default(add_tested=True, add_reviewers=False)) job.execute() assert api.state == 'merged' assert api.notes == []
def test_succeeds_first_time(self, unused_time_sleep): api, mocklab = self.api, self.mocklab with mocklab.branch_update(): job = self.make_job( marge.job.MergeJobOptions.default(add_tested=True, add_reviewers=False)) job.execute() assert api.state == 'merged' assert api.notes == []
def test_waits_for_approvals(self, mock_log, unused_time_sleep): api, mocklab = self.api, self.mocklab with patch('marge.job.update_from_target_branch_and_push', side_effect=mocklab.push_updated): job = self.make_job( marge.job.MergeJobOptions.default(approval_timeout=timedelta(seconds=5), reapprove=True)) job.execute() mock_log.info.assert_any_call('Checking if approvals have reset') mock_log.debug.assert_any_call('Approvals haven\'t reset yet, sleeping for %s secs', ANY) assert api.state == 'merged'
def test_succeeds_first_time(self, api, mocklab): with mocklab.branch_update(): job = self.make_job( api, mocklab, options=marge.job.MergeJobOptions.default(add_tested=True, add_reviewers=False), ) job.execute() assert api.state == 'merged' assert api.notes == []
def test_fails_if_changes_already_exist(self, api, mocklab): expected_message = 'these changes already exist in branch `{}`'.format( mocklab.merge_request_info['target_branch'], ) with mocklab.expected_failure(expected_message): job = self.make_job(api, mocklab) job.repo.rebase.return_value = mocklab.initial_master_sha job.repo.get_commit_hash.return_value = mocklab.initial_master_sha job.execute() assert api.state == 'initial' assert api.notes == ["I couldn't merge this branch: {}".format(expected_message)]
def test_waits_for_approvals(self, mock_log, api, mocklab): with mocklab.branch_update(): job = self.make_job( api, mocklab, options=marge.job.MergeJobOptions.default( approval_timeout=timedelta(seconds=5), reapprove=True, ), ) job.execute() mock_log.info.assert_any_call('Checking if approvals have reset') mock_log.debug.assert_any_call('Approvals haven\'t reset yet, sleeping for %s secs', ANY) assert api.state == 'merged'