From c18cb0d3c886844f39b54ae3ee3ded3fa4c8fcf9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 21 2015 17:16:16 +0000 Subject: Add unit-tests for the new_request_pull endpoint from an empty forked repo --- diff --git a/tests/test_progit_flask_ui_fork.py b/tests/test_progit_flask_ui_fork.py index d944333..1e67fa9 100644 --- a/tests/test_progit_flask_ui_fork.py +++ b/tests/test_progit_flask_ui_fork.py @@ -1354,6 +1354,39 @@ index 0000000..2a552bb '
  • Fork is empty, there are no commits to ' 'request pulling
  • ', output.data) + @patch('pagure.lib.notify.send_email') + def test_new_request_pull_empty_fork(self, send_email): + """ Test the new_request_pull endpoint against an empty repo. """ + send_email.return_value = True + + self.test_fork_project() + + tests.create_projects_git( + os.path.join(tests.HERE, 'requests'), bare=True) + + repo = pagure.lib.get_project(self.session, 'test') + fork = pagure.lib.get_project(self.session, 'test', user='foo') + + # Create a git repo to play with + gitrepo = os.path.join(tests.HERE, 'repos', 'test.git') + repo = pygit2.init_repository(gitrepo, bare=True) + + # Create a fork of this repo + newpath = tempfile.mkdtemp(prefix='pagure-fork-test') + gitrepo = os.path.join(tests.HERE, 'forks', 'foo', 'test.git') + new_repo = pygit2.clone_repository(gitrepo, newpath) + + user = tests.FakeUser() + user.username = 'foo' + with tests.user_set(pagure.APP, user): + output = self.app.get( + '/fork/foo/test/diff/master..master', follow_redirects=True) + self.assertIn( + 'Overview - test - Pagure', output.data) + self.assertIn( + '
  • Fork is empty, there are no commits to ' + 'request pulling
  • ', output.data) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureFlaskForktests)