Blame tests/test_pagure_flask_ui_issues_read_only.py

Pierre-Yves Chibon b59748
# -*- coding: utf-8 -*-
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
"""
Pierre-Yves Chibon b59748
 (c) 2018 - Copyright Red Hat Inc
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
 Authors:
Pierre-Yves Chibon b59748
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
"""
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
from __future__ import unicode_literals
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
import json
Pierre-Yves Chibon b59748
import unittest
Pierre-Yves Chibon b59748
import sys
Pierre-Yves Chibon b59748
import os
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
from mock import patch, MagicMock
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
sys.path.insert(0, os.path.join(os.path.dirname(
Pierre-Yves Chibon b59748
    os.path.abspath(__file__)), '..'))
Pierre-Yves Chibon b59748
Pierre-Yves Chibon 930073
import pagure.lib.query  # noqa
Pierre-Yves Chibon b59748
import tests  # noqa
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
class PagureFlaskIssuesReadOnlytests(tests.Modeltests):
Pierre-Yves Chibon b59748
    """ Tests for flask issues controller of pagure with read-only tickets
Pierre-Yves Chibon b59748
    """
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
Pierre-Yves Chibon b59748
    def setUp(self):
Pierre-Yves Chibon b59748
        """ Set up the environnment, ran before every tests. """
Pierre-Yves Chibon b59748
        super(PagureFlaskIssuesReadOnlytests, self).setUp()
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
        tests.create_projects(self.session)
Pierre-Yves Chibon b59748
        tests.create_projects_git(os.path.join(self.path, 'repos'))
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
        # Make the project's issue tracker read-only
Pierre-Yves Chibon 930073
        repo = pagure.lib.query.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon b59748
        settings = repo.settings
Pierre-Yves Chibon b59748
        settings['issue_tracker_read_only'] = True
Pierre-Yves Chibon b59748
        repo.settings = settings
Pierre-Yves Chibon b59748
        self.session.add(repo)
Pierre-Yves Chibon b59748
        self.session.commit()
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
        # Create a couple of issue
Pierre-Yves Chibon 930073
        msg = pagure.lib.query.new_issue(
Pierre-Yves Chibon b59748
            session=self.session,
Pierre-Yves Chibon b59748
            repo=repo,
Pierre-Yves Chibon b59748
            title='Test issue #1',
Pierre-Yves Chibon b59748
            content='We should work on this for the second time',
Pierre-Yves Chibon b59748
            user='foo',
Pierre-Yves Chibon b59748
            status='Open',
Pierre-Yves Chibon b59748
            private=True,
Pierre-Yves Chibon b59748
        )
Pierre-Yves Chibon b59748
        self.session.commit()
Pierre-Yves Chibon b59748
        self.assertEqual(msg.title, 'Test issue #1')
Pierre-Yves Chibon b59748
Pierre-Yves Chibon 930073
        msg = pagure.lib.query.new_issue(
Pierre-Yves Chibon b59748
            session=self.session,
Pierre-Yves Chibon b59748
            repo=repo,
Pierre-Yves Chibon b59748
            title='Test issue #2',
Pierre-Yves Chibon b59748
            content='We should work on this for the second time',
Pierre-Yves Chibon b59748
            user='foo',
Pierre-Yves Chibon b59748
            status='Open',
Pierre-Yves Chibon b59748
            private=False,
Pierre-Yves Chibon b59748
        )
Pierre-Yves Chibon b59748
        self.session.commit()
Pierre-Yves Chibon b59748
        self.assertEqual(msg.title, 'Test issue #2')
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_issue_list_authenticated_commit(self):
Pierre-Yves Chibon b59748
        """ Test the list of issues when user is authenticated and has
Pierre-Yves Chibon b59748
        access to the project.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.get('/test/issues')
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Issues - test - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon 585e6c
                ''
Pierre-Yves Chibon 585e6c
                ' 2 Open Issues\n', output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_field_comment(self):
Pierre-Yves Chibon b59748
        """ Test if the field commit is present on the issue page.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.get('/test/issue/1')
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Issue #1: Test issue #1 - test - Pagure</title>',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
            self.assertNotIn(
Pierre-Yves Chibon b59748
                'value="Update Issue" title="Comment and Update Metadata" '
Pierre-Yves Chibon b59748
                'tabindex=2 />', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                'This issue tracker is read-only.', output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_update_ticket(self):
Pierre-Yves Chibon b59748
        """ Test updating a ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post(
Pierre-Yves Chibon b59748
                '/test/issue/1/update', data={}, follow_redirects=True)
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_edit_comment(self):
Pierre-Yves Chibon b59748
        """ Test editing a comment from a ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post(
Pierre-Yves Chibon b59748
                '/test/issue/1/comment/1/edit', data={},
Pierre-Yves Chibon b59748
                follow_redirects=True)
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_edit_ticket(self):
Pierre-Yves Chibon b59748
        """ Test editing a ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post(
Pierre-Yves Chibon b59748
                '/test/issue/1/edit', data={}, follow_redirects=True)
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_new_issue(self):
Pierre-Yves Chibon b59748
        """ Test creating a new ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/test/new_issue/', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_deleting_issue(self):
Pierre-Yves Chibon b59748
        """ Test deleting a new ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/test/issue/1/drop', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_uploading_to_issue(self):
Pierre-Yves Chibon b59748
        """ Test uploading to a new ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/test/issue/1/upload', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon b59748
            self.assertIn(
Pierre-Yves Chibon b59748
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon b59748
                output_text)
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
class PagureFlaskAPIIssuesReadOnlytests(PagureFlaskIssuesReadOnlytests):
Pierre-Yves Chibon b59748
    """ Tests for flask API issues controller of pagure with read-only tickets
Pierre-Yves Chibon b59748
    """
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
Pierre-Yves Chibon b59748
    def setUp(self):
Pierre-Yves Chibon b59748
        """ Set up the environnment, ran before every tests. """
Pierre-Yves Chibon b59748
        super(PagureFlaskAPIIssuesReadOnlytests, self).setUp()
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_new_issue(self):
Pierre-Yves Chibon b59748
        """ Test creating a new ticket.
Pierre-Yves Chibon b59748
        """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/new_issue', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_change_status_issue(self):
Pierre-Yves Chibon b59748
        """ Test closing a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/status', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_change_milestone_issue(self):
Pierre-Yves Chibon b59748
        """ Test change the milestone of a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/milestone', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_comment_issue(self):
Pierre-Yves Chibon b59748
        """ Test comment on a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/comment', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_assign_issue(self):
Pierre-Yves Chibon b59748
        """ Test assigning a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/assign', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_subscribe_issue(self):
Pierre-Yves Chibon b59748
        """ Test subscribing to a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/subscribe', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_update_custom_field(self):
Pierre-Yves Chibon b59748
        """ Test updating a specific custom fields on a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/custom/foo', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
    def test_api_update_custom_fields(self):
Pierre-Yves Chibon b59748
        """ Test updating custom fields on a ticket. """
Pierre-Yves Chibon b59748
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon b59748
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon b59748
            output = self.app.post('/api/0/test/issue/1/custom', data={})
Pierre-Yves Chibon b59748
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon b59748
            data = json.loads(output.get_data(as_text=True))
Pierre-Yves Chibon b59748
            self.assertEqual(
Pierre-Yves Chibon b59748
                data,
Pierre-Yves Chibon b59748
                {
Pierre-Yves Chibon b59748
                    u'error': u'The issue tracker of this project is read-only',
Pierre-Yves Chibon b59748
                    u'error_code': u'ETRACKERREADONLY'
Pierre-Yves Chibon b59748
                }
Pierre-Yves Chibon b59748
            )
Pierre-Yves Chibon b59748
Pierre-Yves Chibon b59748
Pierre-Yves Chibon f2c200
class PagureFlaskIssuesAndPRDisabledtests(tests.Modeltests):
Pierre-Yves Chibon f2c200
    """ Tests for flask issues controller of pagure with tickets and PRs
Pierre-Yves Chibon f2c200
    disabled.
Pierre-Yves Chibon f2c200
    """
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
    @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
Pierre-Yves Chibon f2c200
    def setUp(self):
Pierre-Yves Chibon f2c200
        """ Set up the environnment, ran before every tests. """
Pierre-Yves Chibon f2c200
        super(PagureFlaskIssuesAndPRDisabledtests, self).setUp()
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
        tests.create_projects(self.session)
Pierre-Yves Chibon f2c200
        tests.create_projects_git(os.path.join(self.path, 'repos'))
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
        # Make the project's issue tracker read-only
Pierre-Yves Chibon 930073
        repo = pagure.lib.query.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon f2c200
        settings = repo.settings
Pierre-Yves Chibon f2c200
        settings['pull_requests'] = False
Pierre-Yves Chibon f2c200
        settings['issue_tracker_read_only'] = True
Pierre-Yves Chibon f2c200
        repo.settings = settings
Pierre-Yves Chibon f2c200
        self.session.add(repo)
Pierre-Yves Chibon f2c200
        self.session.commit()
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
        # Create a couple of issue
Pierre-Yves Chibon 930073
        msg = pagure.lib.query.new_issue(
Pierre-Yves Chibon f2c200
            session=self.session,
Pierre-Yves Chibon f2c200
            repo=repo,
Pierre-Yves Chibon f2c200
            title='Test issue #1',
Pierre-Yves Chibon f2c200
            content='We should work on this for the second time',
Pierre-Yves Chibon f2c200
            user='foo',
Pierre-Yves Chibon f2c200
            status='Open',
Pierre-Yves Chibon f2c200
            private=True,
Pierre-Yves Chibon f2c200
        )
Pierre-Yves Chibon f2c200
        self.session.commit()
Pierre-Yves Chibon f2c200
        self.assertEqual(msg.title, 'Test issue #1')
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon 930073
        msg = pagure.lib.query.new_issue(
Pierre-Yves Chibon f2c200
            session=self.session,
Pierre-Yves Chibon f2c200
            repo=repo,
Pierre-Yves Chibon f2c200
            title='Test issue #2',
Pierre-Yves Chibon f2c200
            content='We should work on this for the second time',
Pierre-Yves Chibon f2c200
            user='foo',
Pierre-Yves Chibon f2c200
            status='Open',
Pierre-Yves Chibon f2c200
            private=False,
Pierre-Yves Chibon f2c200
        )
Pierre-Yves Chibon f2c200
        self.session.commit()
Pierre-Yves Chibon f2c200
        self.assertEqual(msg.title, 'Test issue #2')
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
    def test_edit_tag(self):
Pierre-Yves Chibon f2c200
        """ Test editing a ticket tag.
Pierre-Yves Chibon f2c200
        """
Pierre-Yves Chibon f2c200
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon f2c200
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon f2c200
            output = self.app.post('/test/tag/tag1/edit', data={})
Pierre-Yves Chibon f2c200
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon f2c200
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon f2c200
            self.assertIn(
Pierre-Yves Chibon f2c200
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon f2c200
            self.assertIn(
Pierre-Yves Chibon f2c200
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon f2c200
                output_text)
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon f2c200
    def test_drop_tags(self):
Pierre-Yves Chibon f2c200
        """ Test dropping a ticket tag.
Pierre-Yves Chibon f2c200
        """
Pierre-Yves Chibon f2c200
        user = tests.FakeUser(username='pingou')
Pierre-Yves Chibon f2c200
        with tests.user_set(self.app.application, user):
Pierre-Yves Chibon f2c200
            output = self.app.post('/test/droptag/', data={})
Pierre-Yves Chibon f2c200
            self.assertEqual(output.status_code, 401)
Pierre-Yves Chibon f2c200
            output_text = output.get_data(as_text=True)
Pierre-Yves Chibon f2c200
            self.assertIn(
Pierre-Yves Chibon f2c200
                '<title>Unauthorized :\'( - Pagure</title>', output_text)
Pierre-Yves Chibon f2c200
            self.assertIn(
Pierre-Yves Chibon f2c200
                '

The issue tracker for this project is read-only

',
Pierre-Yves Chibon f2c200
                output_text)
Pierre-Yves Chibon f2c200
Pierre-Yves Chibon b59748
if __name__ == '__main__':
Pierre-Yves Chibon b59748
    unittest.main(verbosity=2)