|
Pierre-Yves Chibon |
30d656 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
(c) 2018 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
Authors:
|
|
Pierre-Yves Chibon |
30d656 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
import unittest
|
|
Pierre-Yves Chibon |
30d656 |
import sys
|
|
Pierre-Yves Chibon |
30d656 |
import os
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
from mock import patch, MagicMock
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Pierre-Yves Chibon |
30d656 |
os.path.abspath(__file__)), '..'))
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
import pagure # noqa
|
|
Pierre-Yves Chibon |
30d656 |
import pagure.lib # noqa
|
|
Pierre-Yves Chibon |
30d656 |
import tests # noqa
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
class PagureFlaskIssuesPrivatetests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
30d656 |
""" Tests for flask issues controller of pagure with private tickets
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
@patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
30d656 |
def setUp(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Set up the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
30d656 |
super(PagureFlaskIssuesPrivatetests, self).setUp()
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
# Create a 3rd user
|
|
Pierre-Yves Chibon |
30d656 |
item = pagure.lib.model.User(
|
|
Pierre-Yves Chibon |
30d656 |
user='random',
|
|
Pierre-Yves Chibon |
30d656 |
fullname='Random user',
|
|
Pierre-Yves Chibon |
30d656 |
password='foo',
|
|
Pierre-Yves Chibon |
30d656 |
default_email='random@bar.com',
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
30d656 |
item = pagure.lib.model.UserEmail(
|
|
Pierre-Yves Chibon |
30d656 |
user_id=3,
|
|
Pierre-Yves Chibon |
30d656 |
email='random@bar.com')
|
|
Pierre-Yves Chibon |
30d656 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
30d656 |
tests.create_projects_git(os.path.join(self.path, 'repos'))
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib.get_authorized_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.new_issue(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
repo=repo,
|
|
Pierre-Yves Chibon |
30d656 |
title='Test issue #1',
|
|
Pierre-Yves Chibon |
30d656 |
content='We should work on this for the second time',
|
|
Pierre-Yves Chibon |
30d656 |
user='foo',
|
|
Pierre-Yves Chibon |
30d656 |
status='Open',
|
|
Pierre-Yves Chibon |
30d656 |
private=True,
|
|
Pierre-Yves Chibon |
30d656 |
ticketfolder=None
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg.title, 'Test issue #1')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.new_issue(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
repo=repo,
|
|
Pierre-Yves Chibon |
30d656 |
title='Test issue #2',
|
|
Pierre-Yves Chibon |
30d656 |
content='We should work on this for the second time',
|
|
Pierre-Yves Chibon |
30d656 |
user='foo',
|
|
Pierre-Yves Chibon |
30d656 |
status='Open',
|
|
Pierre-Yves Chibon |
30d656 |
private=False,
|
|
Pierre-Yves Chibon |
30d656 |
ticketfolder=None
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg.title, 'Test issue #2')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_anonymous(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is logged out. """
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 1 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_admin(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is an admin of the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='pingou')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 2 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_author(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is an admin of the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='foo')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 2 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_authenticated(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is authenticated but has no
|
|
Pierre-Yves Chibon |
30d656 |
special access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 1 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_authenticated_ticket(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is authenticated but has
|
|
Pierre-Yves Chibon |
30d656 |
ticket level access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.add_user_to_project(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
project=repo,
|
|
Pierre-Yves Chibon |
30d656 |
new_user='random',
|
|
Pierre-Yves Chibon |
30d656 |
user='pingou',
|
|
Pierre-Yves Chibon |
30d656 |
access='ticket',
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg, 'User added')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 1 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_authenticated_commit(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is authenticated but has
|
|
Pierre-Yves Chibon |
30d656 |
commit level access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.add_user_to_project(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
project=repo,
|
|
Pierre-Yves Chibon |
30d656 |
new_user='random',
|
|
Pierre-Yves Chibon |
30d656 |
user='pingou',
|
|
Pierre-Yves Chibon |
30d656 |
access='commit',
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg, 'User added')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 2 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_issue_list_authenticated_assigned(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test the list of issues when user is authenticated and is
|
|
Pierre-Yves Chibon |
30d656 |
assigned to one of the issue.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
issue = pagure.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
30d656 |
issue.assignee_id = 3 # random
|
|
Pierre-Yves Chibon |
30d656 |
self.session.add(issue)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issues')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'\n 2 Open Issues', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_anonymous(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is logged out. """
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_admin(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is an admin of the
|
|
Pierre-Yves Chibon |
30d656 |
project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='pingou')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'<title>Issue #1: Test issue #1 - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
30d656 |
output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_author(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user opened the ticket.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='foo')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'<title>Issue #1: Test issue #1 - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
30d656 |
output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_authenticated(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is authenticated but
|
|
Pierre-Yves Chibon |
30d656 |
has no special access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_authenticated_ticket(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is authenticated and
|
|
Pierre-Yves Chibon |
30d656 |
has ticket level access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.add_user_to_project(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
project=repo,
|
|
Pierre-Yves Chibon |
30d656 |
new_user='random',
|
|
Pierre-Yves Chibon |
30d656 |
user='pingou',
|
|
Pierre-Yves Chibon |
30d656 |
access='ticket',
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg, 'User added')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_authenticated_commit(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is authenticated and
|
|
Pierre-Yves Chibon |
30d656 |
has commit level access to the project.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
msg = pagure.lib.add_user_to_project(
|
|
Pierre-Yves Chibon |
30d656 |
session=self.session,
|
|
Pierre-Yves Chibon |
30d656 |
project=repo,
|
|
Pierre-Yves Chibon |
30d656 |
new_user='random',
|
|
Pierre-Yves Chibon |
30d656 |
user='pingou',
|
|
Pierre-Yves Chibon |
30d656 |
access='commit',
|
|
Pierre-Yves Chibon |
30d656 |
)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(msg, 'User added')
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'<title>Issue #1: Test issue #1 - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
30d656 |
output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
def test_view_issue_authenticated_assigned(self):
|
|
Pierre-Yves Chibon |
30d656 |
""" Test accessing a private ticket when user is authenticated and
|
|
Pierre-Yves Chibon |
30d656 |
is assigned to one of the issue.
|
|
Pierre-Yves Chibon |
30d656 |
"""
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
repo = pagure.lib._get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
30d656 |
issue = pagure.lib.search_issues(self.session, repo, issueid=1)
|
|
Pierre-Yves Chibon |
30d656 |
issue.assignee_id = 3 # random
|
|
Pierre-Yves Chibon |
30d656 |
self.session.add(issue)
|
|
Pierre-Yves Chibon |
30d656 |
self.session.commit()
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
user = tests.FakeUser(username='random')
|
|
Pierre-Yves Chibon |
30d656 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
30d656 |
output = self.app.get('/test/issue/1')
|
|
Pierre-Yves Chibon |
30d656 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'div class="projectinfo m-t-1 m-b-1">\ntest project #1'
|
|
Pierre-Yves Chibon |
e30e84 |
u' ', output.data)
|
|
Pierre-Yves Chibon |
30d656 |
self.assertIn(
|
|
Pierre-Yves Chibon |
30d656 |
u'<title>Issue #1: Test issue #1 - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
30d656 |
output.data)
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
|
|
Pierre-Yves Chibon |
30d656 |
if __name__ == '__main__':
|
|
Pierre-Yves Chibon |
30d656 |
unittest.main(verbosity=2)
|