From fb36e787e1bd50e5d06942e585be600e0e5f47ce Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2015 11:40:46 +0000 Subject: Add unit-tests when merge_pull_request fails to due a conflict --- diff --git a/tests/test_progit_flask_ui_fork.py b/tests/test_progit_flask_ui_fork.py index e707258..15f4038 100644 --- a/tests/test_progit_flask_ui_fork.py +++ b/tests/test_progit_flask_ui_fork.py @@ -390,6 +390,40 @@ class PagureFlaskForktests(tests.Modeltests): self.assertIn( '
  • Changes merged!
  • ', output.data) + @patch('pagure.lib.notify.send_email') + def test_merge_request_pull_conflicts(self, send_email): + """ Test the merge_request_pull endpoint with a conflicting PR. """ + send_email.return_value = True + + tests.create_projects(self.session) + tests.create_projects_git( + os.path.join(tests.HERE, 'requests'), bare=True) + self.set_up_git_repo( + new_project=None, branch_from='feature', mtype='conflicts') + + user = tests.FakeUser() + user.username = 'pingou' + with tests.user_set(pagure.APP, user): + output = self.app.get('/test/pull-request/1') + self.assertEqual(output.status_code, 200) + + csrf_token = output.data.split( + 'name="csrf_token" type="hidden" value="')[1].split('">')[0] + + data = { + 'csrf_token': csrf_token, + } + + # Merge conflicts + output = self.app.post( + '/test/pull-request/1/merge', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertIn( + 'Pull request #1 - test - Pagure', + output.data) + self.assertIn( + '
  • Merge conflicts!
  • ', output.data) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureFlaskForktests)