diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 8f712d8..73a3e86 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -512,6 +512,84 @@ class PagureFlaskApptests(tests.Modeltests): self.assertTrue(os.path.exists( os.path.join(self.path, 'repos', 'requests', '%s.git' % project))) + @patch('pygit2.init_repository', wraps=pygit2.init_repository) + def test_new_project_with_template(self, pygit2init): + """ Test the new_project endpoint for a new project with a template set. + """ + # Before + projects = pagure.lib.search_projects(self.session) + self.assertEqual(len(projects), 0) + self.assertFalse(os.path.exists( + os.path.join(self.path, 'repos', 'project-1.git'))) + self.assertFalse(os.path.exists( + os.path.join(self.path, 'repos', 'tickets', 'project-1.git'))) + self.assertFalse(os.path.exists( + os.path.join(self.path, 'repos', 'docs', 'project-1.git'))) + self.assertFalse(os.path.exists( + os.path.join(self.path, 'repos', 'requests', 'project-1.git'))) + + user = tests.FakeUser() + user.username = 'foo' + with tests.user_set(self.app.application, user): + output = self.app.get('/new/') + self.assertEqual(output.status_code, 200) + self.assertIn( + b'Create new Project', output.data) + + csrf_token = self.get_csrf(output=output) + + data = { + 'description': 'test', + 'name': 'project-1', + 'csrf_token': csrf_token, + 'create_readme': True, + } + output = self.app.post('/new/', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertIn( + '