From ce6f3057bc26a3025673fba6e94adef397af6fe6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 04 2016 08:29:05 +0000 Subject: Expand the unit-tests on view_user_issues and view_user_requests This should help avoiding the issue we ran into in 2.10 --- diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 150b60d..95d1e0b 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -18,7 +18,7 @@ import os import six import json -from mock import patch +from mock import patch, MagicMock sys.path.insert(0, os.path.join(os.path.dirname( os.path.abspath(__file__)), '..')) @@ -923,30 +923,142 @@ class PagureFlaskApptests(tests.Modeltests): self.assertEqual(output.status_code, 302) -class ViewMyRequestsTests(tests.Modeltests): - def test_view_my_requests_no_user(self): - """Test the endpoint.""" + """Test the view_user_requests endpoint.""" output = self.app.get('/user/somenonexistentuser/requests') self.assertEqual(output.status_code, 404) + @patch( + 'pagure.lib.git.update_git', MagicMock(return_value=True)) + @patch( + 'pagure.lib.notify.send_email', MagicMock(return_value=True)) def test_view_my_requests(self): - """Test the index endpoint. """ + """Test the view_user_requests endpoint. """ + # Create the PR + tests.create_projects(self.session) + repo = pagure.lib.get_project(self.session, 'test') + req = pagure.lib.new_pull_request( + session=self.session, + repo_from=repo, + branch_from='dev', + repo_to=repo, + branch_to='master', + title='test pull-request #1', + user='pingou', + requestfolder=None, + ) + self.session.commit() + self.assertEqual(req.id, 1) + self.assertEqual(req.title, 'test pull-request #1') + output = self.app.get('/user/pingou/requests') self.assertEqual(output.status_code, 200) + self.assertIn('test pull-request #1', output.data) + self.assertEqual( + output.data.count('