diff --git a/tests/test_progit_flask_ui_issues.py b/tests/test_progit_flask_ui_issues.py index 992928a..7a095d2 100644 --- a/tests/test_progit_flask_ui_issues.py +++ b/tests/test_progit_flask_ui_issues.py @@ -333,6 +333,14 @@ class PagureFlaskIssuestests(tests.Modeltests): 'status': 'fixed' } + # Invalid repo + output = self.app.post('/bar/issue/1/update', data=data) + self.assertEqual(output.status_code, 404) + + # Non-existing issue + output = self.app.post('/test/issue/100/update', data=data) + self.assertEqual(output.status_code, 404) + output = self.app.post( '/test/issue/1/update', data=data, follow_redirects=True) self.assertEqual(output.status_code, 200) @@ -534,6 +542,105 @@ class PagureFlaskIssuestests(tests.Modeltests): output = self.app.get('/test/issue/1/update') self.assertEqual(output.status_code, 302) + # Repo not set-up for issue tracker + output = self.app.post('/test/issue/1/update', data=data) + self.assertEqual(output.status_code, 404) + + @patch('pagure.lib.git.update_git') + @patch('pagure.lib.notify.send_email') + def test_update_issue_drop_comment(self, p_send_email, p_ugt): + """ Test droping comment via the update_issue endpoint. """ + p_send_email.return_value = True + p_ugt.return_value = True + + tests.create_projects(self.session) + + # Create issues to play with + repo = pagure.lib.get_project(self.session, 'test') + msg = pagure.lib.new_issue( + session=self.session, + repo=repo, + title='Test issue', + content='We should work on this', + user='pingou', + ticketfolder=None + ) + self.session.commit() + self.assertEqual(msg.title, 'Test issue') + + user = tests.FakeUser() + user.username = 'pingou' + with tests.user_set(pagure.APP, user): + output = self.app.get('/test/issue/1') + self.assertEqual(output.status_code, 200) + self.assertTrue( + '
test project #1
' + in output.data) + + csrf_token = output.data.split( + 'name="csrf_token" type="hidden" value="')[1].split('">')[0] + + # Add new comment + data = { + 'csrf_token': csrf_token, + 'comment': 'Woohoo a second comment !', + } + output = self.app.post( + '/test/issue/1/update', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertTrue( + 'test project #1
' + in output.data) + self.assertTrue( + ' ' in output.data) + self.assertTrue( + 'Woohoo a second comment !
' in output.data) + self.assertEqual( + output.data.count('
test project #1
' + in output.data) + self.assertTrue( + ' ' in output.data) + + # Drop non-existant comment + output = self.app.post( + '/test/issue/1/update', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 404) + + repo = pagure.lib.get_project(self.session, 'test') + issue = pagure.lib.search_issues(self.session, repo, issueid=1) + self.assertEqual(len(issue.comments), 0) + @patch('pagure.lib.git.update_git') @patch('pagure.lib.notify.send_email') def test_edit_issue(self, p_send_email, p_ugt):