Blame tests/test_pagure_flask_ui_priorities.py

Pierre-Yves Chibon af88e9
# -*- coding: utf-8 -*-
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
"""
Pierre-Yves Chibon af88e9
 (c) 2016 - Copyright Red Hat Inc
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
 Authors:
Pierre-Yves Chibon af88e9
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
"""
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
__requires__ = ['SQLAlchemy >= 0.8']
Pierre-Yves Chibon af88e9
import pkg_resources
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
import datetime
Pierre-Yves Chibon af88e9
import json
Pierre-Yves Chibon af88e9
import unittest
Pierre-Yves Chibon af88e9
import shutil
Pierre-Yves Chibon af88e9
import sys
Pierre-Yves Chibon af88e9
import tempfile
Pierre-Yves Chibon af88e9
import os
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
import pygit2
Pierre-Yves Chibon dff667
from mock import patch, MagicMock
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
sys.path.insert(0, os.path.join(os.path.dirname(
Pierre-Yves Chibon af88e9
    os.path.abspath(__file__)), '..'))
Pierre-Yves Chibon af88e9
Farhaan Bukhsh 72e9db
import pagure
Pierre-Yves Chibon af88e9
import pagure.lib
Pierre-Yves Chibon af88e9
import tests
Pierre-Yves Chibon af88e9
from pagure.lib.repo import PagureRepo
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
class PagureFlaskPrioritiestests(tests.Modeltests):
Pierre-Yves Chibon af88e9
    """ Tests for the behavior of priorities in pagure """
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
    def setUp(self):
Pierre-Yves Chibon af88e9
        """ Set up the environnment, ran before every tests. """
Pierre-Yves Chibon af88e9
        super(PagureFlaskPrioritiestests, self).setUp()
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        pagure.APP.config['TESTING'] = True
Pierre-Yves Chibon af88e9
        pagure.SESSION = self.session
Pierre-Yves Chibon af88e9
        pagure.ui.SESSION = self.session
Pierre-Yves Chibon af88e9
        pagure.ui.app.SESSION = self.session
Pierre-Yves Chibon af88e9
        pagure.ui.filters.SESSION = self.session
Pierre-Yves Chibon af88e9
        pagure.ui.repo.SESSION = self.session
Pierre-Yves Chibon af88e9
        pagure.ui.issues.SESSION = self.session
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
    @patch('pagure.lib.git.update_git')
Pierre-Yves Chibon af88e9
    @patch('pagure.lib.notify.send_email')
Pierre-Yves Chibon af88e9
    def test_ticket_with_no_priority(self, p_send_email, p_ugt):
Pierre-Yves Chibon af88e9
        """ Test creating a ticket without priority. """
Pierre-Yves Chibon af88e9
        p_send_email.return_value = True
Pierre-Yves Chibon af88e9
        p_ugt.return_value = True
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        tests.create_projects(self.session)
Patrick Uiterwijk 170974
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        user = tests.FakeUser()
Pierre-Yves Chibon af88e9
        user.username = 'pingou'
Pierre-Yves Chibon af88e9
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            # Get the CSRF token
Pierre-Yves Chibon af88e9
            output = self.app.get('/test/new_issue')
Pierre-Yves Chibon af88e9
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon af88e9
            self.assertTrue(
Pierre-Yves Chibon af88e9
                '
\n New issue'
Pierre-Yves Chibon af88e9
                in output.data)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            csrf_token = output.data.split(
Pierre-Yves Chibon af88e9
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            data = {
Pierre-Yves Chibon af88e9
                'title': 'Test issue',
Pierre-Yves Chibon af88e9
                'issue_content': 'We really should improve on this issue',
Pierre-Yves Chibon af88e9
                'status': 'Open',
Pierre-Yves Chibon af88e9
                'csrf_token': csrf_token,
Pierre-Yves Chibon af88e9
            }
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            # Create the issue
Pierre-Yves Chibon af88e9
            output = self.app.post(
Pierre-Yves Chibon af88e9
                '/test/new_issue', data=data, follow_redirects=True)
Pierre-Yves Chibon af88e9
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon af88e9
            self.assertIn(
Pierre-Yves Chibon af88e9
                '<title>Issue #1: Test issue - test - Pagure</title>',
Pierre-Yves Chibon af88e9
                output.data)
Pierre-Yves Chibon af88e9
            self.assertIn(
Pierre-Yves Chibon af88e9
                '
Pierre-Yves Chibon af88e9
                'href="/test/issue/1/edit" title="Edit this issue">',
Pierre-Yves Chibon af88e9
                output.data)
Pierre-Yves Chibon af88e9
            self.assertNotIn('
', output.data)
Pierre-Yves Chibon af88e9
            self.assertNotIn('<option value="1">High</option>', output.data)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
    @patch('pagure.lib.git.update_git')
Pierre-Yves Chibon af88e9
    @patch('pagure.lib.notify.send_email')
Pierre-Yves Chibon af88e9
    def test_ticket_with_priorities(self, p_send_email, p_ugt):
Pierre-Yves Chibon af88e9
        """ Test creating a ticket with priorities. """
Pierre-Yves Chibon af88e9
        p_send_email.return_value = True
Pierre-Yves Chibon af88e9
        p_ugt.return_value = True
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        tests.create_projects(self.session)
Patrick Uiterwijk 170974
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        # Set some priorities
Farhaan Bukhsh 72e9db
        repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon af88e9
        repo.priorities = {'1': 'High', '2': 'Normal'}
Pierre-Yves Chibon af88e9
        self.session.add(repo)
Pierre-Yves Chibon af88e9
        self.session.commit()
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
        user = tests.FakeUser()
Pierre-Yves Chibon af88e9
        user.username = 'pingou'
Pierre-Yves Chibon af88e9
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            # Get the CSRF token
Pierre-Yves Chibon af88e9
            output = self.app.get('/test/new_issue')
Pierre-Yves Chibon af88e9
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon af88e9
            self.assertTrue(
Pierre-Yves Chibon af88e9
                '
\n New issue'
Pierre-Yves Chibon af88e9
                in output.data)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            csrf_token = output.data.split(
Pierre-Yves Chibon af88e9
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            data = {
Pierre-Yves Chibon af88e9
                'title': 'Test issue',
Pierre-Yves Chibon af88e9
                'issue_content': 'We really should improve on this issue',
Pierre-Yves Chibon af88e9
                'status': 'Open',
Pierre-Yves Chibon af88e9
                'csrf_token': csrf_token,
Pierre-Yves Chibon af88e9
            }
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
            # Create the issue
Pierre-Yves Chibon af88e9
            output = self.app.post(
Pierre-Yves Chibon af88e9
                '/test/new_issue', data=data, follow_redirects=True)
Pierre-Yves Chibon af88e9
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon af88e9
            self.assertIn(
Pierre-Yves Chibon af88e9
                '<title>Issue #1: Test issue - test - Pagure</title>',
Pierre-Yves Chibon af88e9
                output.data)
Pierre-Yves Chibon af88e9
            self.assertIn(
Pierre-Yves Chibon af88e9
                '
Pierre-Yves Chibon af88e9
                'href="/test/issue/1/edit" title="Edit this issue">',
Pierre-Yves Chibon af88e9
                output.data)
Pierre-Yves Chibon af88e9
            self.assertIn('
', output.data)
Pierre-Yves Chibon af88e9
            self.assertIn('<option value="1">High</option>', output.data)
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon 3d1519
    def test_update_priorities(self):
Pierre-Yves Chibon 3d1519
        """ Test updating priorities of a repo. """
Pierre-Yves Chibon 3d1519
        tests.create_projects(self.session)
Patrick Uiterwijk 170974
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
        # Set some priorities
Farhaan Bukhsh 72e9db
        repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
        self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
        user = tests.FakeUser()
Pierre-Yves Chibon 3d1519
        user.username = 'pingou'
Pierre-Yves Chibon 3d1519
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Get the CSRF token
Pierre-Yves Chibon 3d1519
            output = self.app.get('/test/settings')
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            csrf_token = output.data.split(
Pierre-Yves Chibon 3d1519
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': 1,
Pierre-Yves Chibon 3d1519
                'priority_title': 'High',
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- None, no CSRF
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': 1,
Pierre-Yves Chibon 3d1519
                'priority_title': 'High',
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- Priority recorded
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon c63cca
            self.assertEqual(repo.priorities, {u'': u'', u'1': u'High'})
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': [1, 2, 3],
Pierre-Yves Chibon 3d1519
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Patrick Uiterwijk a764eb
            # Check the ordering
Patrick Uiterwijk a764eb
            self.assertTrue(
Patrick Uiterwijk a764eb
                output.data.find('High') < output.data.find('Normal'))
Patrick Uiterwijk a764eb
            self.assertTrue(
Patrick Uiterwijk a764eb
                output.data.find('Normal') < output.data.find('Low'))
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- Priority recorded
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(
Pierre-Yves Chibon 3d1519
                repo.priorities,
Pierre-Yves Chibon c63cca
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 3d1519
            )
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Check error - less weigths than titles
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': [1, 2],
Pierre-Yves Chibon 3d1519
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '\n'
Pierre-Yves Chibon 3d1519
                '                      Priorities weights and titles are '
Pierre-Yves Chibon 3d1519
                'not of the same length', output.data)            # Check the result of the action -- Priorities un-changed
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(
Pierre-Yves Chibon 3d1519
                repo.priorities,
Pierre-Yves Chibon c63cca
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 3d1519
            )
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Check error - weigths must be integer
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': [1, 2, 'c'],
Pierre-Yves Chibon 3d1519
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '\n'
Pierre-Yves Chibon 3d1519
                '                      Priorities weights must be numbers',
Pierre-Yves Chibon 3d1519
                output.data)
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- Priorities un-changed
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(
Pierre-Yves Chibon 3d1519
                repo.priorities,
Pierre-Yves Chibon c63cca
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 3d1519
            )
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Check error - Twice the same priority weigth
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': [1, 2, 2],
Pierre-Yves Chibon 3d1519
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '\n'
Pierre-Yves Chibon 3d1519
                '                      Priority weight 2 is present 2 times',
Pierre-Yves Chibon 3d1519
                output.data)
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- Priorities un-changed
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(
Pierre-Yves Chibon 3d1519
                repo.priorities,
Pierre-Yves Chibon c63cca
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 3d1519
            )
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Check error - Twice the same priority title
Pierre-Yves Chibon 3d1519
            data = {
Pierre-Yves Chibon 3d1519
                'priority_weigth': [1, 2, 3],
Pierre-Yves Chibon 3d1519
                'priority_title': ['High', 'Normal', 'Normal'],
Pierre-Yves Chibon 3d1519
                'csrf_token': csrf_token,
Pierre-Yves Chibon 3d1519
            }
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 3d1519
            # Check the redirect
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 3d1519
            self.assertIn(
Pierre-Yves Chibon 3d1519
                '\n'
Pierre-Yves Chibon 3d1519
                '                      Priority Normal is present 2 times',
Pierre-Yves Chibon 3d1519
                output.data)
Pierre-Yves Chibon 3d1519
            # Check the result of the action -- Priorities un-changed
Farhaan Bukhsh 72e9db
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 3d1519
            self.assertEqual(
Pierre-Yves Chibon 3d1519
                repo.priorities,
Pierre-Yves Chibon c63cca
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 3d1519
            )
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            # Check the behavior if the project disabled the issue tracker
Pierre-Yves Chibon 3d1519
            settings = repo.settings
Pierre-Yves Chibon 3d1519
            settings['issue_tracker'] = False
Pierre-Yves Chibon 3d1519
            repo.settings = settings
Pierre-Yves Chibon 3d1519
            self.session.add(repo)
Pierre-Yves Chibon 3d1519
            self.session.commit()
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 3d1519
            output = self.app.post(
Pierre-Yves Chibon 3d1519
                '/test/update/priorities', data=data)
Pierre-Yves Chibon 3d1519
            self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 3d1519
Pierre-Yves Chibon 068320
            # Check for an invalid project
Pierre-Yves Chibon 068320
            output = self.app.post(
Pierre-Yves Chibon 068320
                '/foo/update/priorities', data=data)
Pierre-Yves Chibon 068320
            self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon 068320
Pierre-Yves Chibon 068320
        # Check for a non-admin user
Pierre-Yves Chibon 068320
        settings = repo.settings
Pierre-Yves Chibon 068320
        settings['issue_tracker'] = True
Pierre-Yves Chibon 068320
        repo.settings = settings
Pierre-Yves Chibon 068320
        self.session.add(repo)
Pierre-Yves Chibon 068320
        self.session.commit()
Pierre-Yves Chibon 068320
Pierre-Yves Chibon 068320
        user.username = 'ralph'
Pierre-Yves Chibon 068320
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon 068320
            output = self.app.post(
Pierre-Yves Chibon 068320
                '/test/update/priorities', data=data)
Pierre-Yves Chibon 068320
            self.assertEqual(output.status_code, 403)
Pierre-Yves Chibon 068320
Pierre-Yves Chibon 7b3aee
    @patch('pagure.lib.git.update_git')
Pierre-Yves Chibon 7b3aee
    @patch('pagure.lib.notify.send_email')
Pierre-Yves Chibon 7b3aee
    def test_reset_priorities(self, p_send_email, p_ugt):
Pierre-Yves Chibon 7b3aee
        """ Test resetting the priorities of a repo. """
Pierre-Yves Chibon 7b3aee
        p_send_email.return_value = True
Pierre-Yves Chibon 7b3aee
        p_ugt.return_value = True
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
        tests.create_projects(self.session)
Patrick Uiterwijk 170974
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
        # Start from scrach on priorities
Farhaan Bukhsh 940880
        repo = pagure.lib._get_project(self.session, 'test')
Pierre-Yves Chibon 7b3aee
        self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
        user = tests.FakeUser()
Pierre-Yves Chibon 7b3aee
        user.username = 'pingou'
Pierre-Yves Chibon 7b3aee
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Get the CSRF token
Pierre-Yves Chibon 7b3aee
            output = self.app.get('/test/settings')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertIn(
Pierre-Yves Chibon 7b3aee
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            csrf_token = output.data.split(
Pierre-Yves Chibon 7b3aee
                'name="csrf_token" type="hidden" value="')[1].split('">')[0]
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Set some priorities
Pierre-Yves Chibon 7b3aee
            data = {
Pierre-Yves Chibon 7b3aee
                'priority_weigth': [1, 2, 3],
Pierre-Yves Chibon 7b3aee
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 7b3aee
                'csrf_token': csrf_token,
Pierre-Yves Chibon 7b3aee
            }
Pierre-Yves Chibon 7b3aee
            output = self.app.post(
Pierre-Yves Chibon 7b3aee
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertIn(
Pierre-Yves Chibon 7b3aee
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Check the result of the action -- Priority recorded
Farhaan Bukhsh 940880
            repo = pagure.lib._get_project(self.session, 'test')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(
Pierre-Yves Chibon 7b3aee
                repo.priorities,
Pierre-Yves Chibon 7b3aee
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 7b3aee
            )
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Create an issue
Pierre-Yves Chibon 7b3aee
            data = {
Pierre-Yves Chibon 7b3aee
                'title': 'Test issue',
Pierre-Yves Chibon 7b3aee
                'issue_content': 'We really should improve on this issue',
Pierre-Yves Chibon 7b3aee
                'status': 'Open',
Pierre-Yves Chibon 7b3aee
                'csrf_token': csrf_token,
Pierre-Yves Chibon 7b3aee
            }
Pierre-Yves Chibon 7b3aee
            output = self.app.post(
Pierre-Yves Chibon 7b3aee
                '/test/new_issue', data=data, follow_redirects=True)
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertIn(
Pierre-Yves Chibon 7b3aee
                '<title>Issue #1: Test issue - test - Pagure</title>',
Pierre-Yves Chibon 7b3aee
                output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn(
Pierre-Yves Chibon 7b3aee
                '
Pierre-Yves Chibon 7b3aee
                'href="/test/issue/1/edit" title="Edit this issue">',
Pierre-Yves Chibon 7b3aee
                output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('
', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('<option value="1">High</option>', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Check that the ticket *does* have priorities
Pierre-Yves Chibon 7b3aee
            output = self.app.get('/test/issue/1')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertIn('
', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('<option value="1">High</option>', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Reset the priorities
Pierre-Yves Chibon 7b3aee
            data = {
Pierre-Yves Chibon 7b3aee
                'csrf_token': csrf_token,
Pierre-Yves Chibon 7b3aee
            }
Pierre-Yves Chibon 7b3aee
            output = self.app.post(
Pierre-Yves Chibon 7b3aee
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertIn(
Pierre-Yves Chibon 7b3aee
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Check that the issue list renders fine
Pierre-Yves Chibon 7b3aee
            output = self.app.get('/test/issues')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Check that the ticket *does not* have priorities
Pierre-Yves Chibon 7b3aee
            output = self.app.get('/test/issue/1')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 7b3aee
            self.assertNotIn('
', output.data)
Pierre-Yves Chibon 7b3aee
            self.assertNotIn('<option value="1">High</option>', output.data)
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon 7b3aee
            # Check the result of the action -- Priority recorded
Farhaan Bukhsh 940880
            repo = pagure.lib._get_project(self.session, 'test')
Pierre-Yves Chibon 7b3aee
            self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon 7b3aee
Pierre-Yves Chibon dff667
    @patch('pagure.lib.git.update_git', MagicMock(return_value=True))
Pierre-Yves Chibon dff667
    @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
Pierre-Yves Chibon dff667
    def test_default_priority(self):
Pierre-Yves Chibon dff667
        """ Test updating the default priority of a repo. """
Pierre-Yves Chibon dff667
        tests.create_projects(self.session)
Pierre-Yves Chibon dff667
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
        # Check the default priorities
Pierre-Yves Chibon dff667
        repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
        self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon dff667
        self.assertEqual(repo.default_priority, None)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
        user = tests.FakeUser()
Pierre-Yves Chibon dff667
        user.username = 'pingou'
Pierre-Yves Chibon dff667
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            csrf_token = self.get_csrf()
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Set some priorities
Pierre-Yves Chibon dff667
            data = {
Pierre-Yves Chibon dff667
                'priority_weigth': [1, 2, 3],
Pierre-Yves Chibon dff667
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon dff667
                'csrf_token': csrf_token,
Pierre-Yves Chibon dff667
            }
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon dff667
            # Check the redirect
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon dff667
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon dff667
            # Check the ordering
Pierre-Yves Chibon dff667
            self.assertTrue(
Pierre-Yves Chibon dff667
                output.data.find('High') < output.data.find('Normal'))
Pierre-Yves Chibon dff667
            self.assertTrue(
Pierre-Yves Chibon dff667
                output.data.find('Normal') < output.data.find('Low'))
Pierre-Yves Chibon dff667
            # Check the result of the action -- Priority recorded
Pierre-Yves Chibon dff667
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
            self.assertEqual(
Pierre-Yves Chibon dff667
                repo.priorities,
Pierre-Yves Chibon dff667
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon dff667
            )
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Try setting the default priority  --  no csrf
Pierre-Yves Chibon dff667
            data = {'priority': 'High'}
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data,
Pierre-Yves Chibon dff667
                follow_redirects=True)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon dff667
            # Check the redirect
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon dff667
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon dff667
            # Check the result of the action -- default_priority no change
Pierre-Yves Chibon dff667
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
            self.assertEqual(repo.default_priority, None)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Try setting the default priority
Pierre-Yves Chibon dff667
            data = {'priority': 'High', 'csrf_token': csrf_token}
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data,
Pierre-Yves Chibon dff667
                follow_redirects=True)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon dff667
            # Check the redirect
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon dff667
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '\n                      Default priority set '
Pierre-Yves Chibon dff667
                'to High', output.data)
Pierre-Yves Chibon dff667
            # Check the result of the action -- default_priority no change
Pierre-Yves Chibon dff667
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
            self.assertEqual(repo.default_priority, 'High')
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Try setting a wrong default priority
Pierre-Yves Chibon dff667
            data = {'priority': 'Smooth', 'csrf_token': csrf_token}
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data,
Pierre-Yves Chibon dff667
                follow_redirects=True)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon dff667
            # Check the redirect
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon dff667
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon dff667
            # Check the result of the action -- default_priority no change
Pierre-Yves Chibon dff667
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
            self.assertEqual(repo.default_priority, 'High')
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # reset the default priority
Pierre-Yves Chibon dff667
            data = {'csrf_token': csrf_token, 'priority': ''}
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data,
Pierre-Yves Chibon dff667
                follow_redirects=True)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon dff667
            # Check the redirect
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon dff667
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon dff667
            self.assertIn(
Pierre-Yves Chibon dff667
                '\n                      Default priority reset',
Pierre-Yves Chibon dff667
                output.data)
Pierre-Yves Chibon dff667
            # Check the result of the action -- default_priority no change
Pierre-Yves Chibon dff667
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon dff667
            self.assertEqual(repo.default_priority, None)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Check the behavior if the project disabled the issue tracker
Pierre-Yves Chibon dff667
            settings = repo.settings
Pierre-Yves Chibon dff667
            settings['issue_tracker'] = False
Pierre-Yves Chibon dff667
            repo.settings = settings
Pierre-Yves Chibon dff667
            self.session.add(repo)
Pierre-Yves Chibon dff667
            self.session.commit()
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
            # Check for an invalid project
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/foo/update/default_priority', data=data)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 404)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
        # Check for a non-admin user
Pierre-Yves Chibon dff667
        settings = repo.settings
Pierre-Yves Chibon dff667
        settings['issue_tracker'] = True
Pierre-Yves Chibon dff667
        repo.settings = settings
Pierre-Yves Chibon dff667
        self.session.add(repo)
Pierre-Yves Chibon dff667
        self.session.commit()
Pierre-Yves Chibon dff667
Pierre-Yves Chibon dff667
        user.username = 'ralph'
Pierre-Yves Chibon dff667
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon dff667
            output = self.app.post(
Pierre-Yves Chibon dff667
                '/test/update/default_priority', data=data)
Pierre-Yves Chibon dff667
            self.assertEqual(output.status_code, 403)
Pierre-Yves Chibon dff667
Pierre-Yves Chibon 606ecb
    @patch('pagure.lib.git.update_git', MagicMock(return_value=True))
Pierre-Yves Chibon 606ecb
    @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))
Pierre-Yves Chibon 606ecb
    def test_default_priority_reset_when_updating_priorities(self):
Pierre-Yves Chibon 606ecb
        """ Test updating the default priority of a repo when updating the
Pierre-Yves Chibon 606ecb
        priorities.
Pierre-Yves Chibon 606ecb
        """
Pierre-Yves Chibon 606ecb
        tests.create_projects(self.session)
Pierre-Yves Chibon 606ecb
        tests.create_projects_git(os.path.join(self.path, 'repos'), bare=True)
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
        # Check the default priorities
Pierre-Yves Chibon 606ecb
        repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 606ecb
        self.assertEqual(repo.priorities, {})
Pierre-Yves Chibon 606ecb
        self.assertEqual(repo.default_priority, None)
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
        user = tests.FakeUser()
Pierre-Yves Chibon 606ecb
        user.username = 'pingou'
Pierre-Yves Chibon 606ecb
        with tests.user_set(pagure.APP, user):
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
            csrf_token = self.get_csrf()
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
            # Set some priorities
Pierre-Yves Chibon 606ecb
            data = {
Pierre-Yves Chibon 606ecb
                'priority_weigth': [1, 2, 3],
Pierre-Yves Chibon 606ecb
                'priority_title': ['High', 'Normal', 'Low'],
Pierre-Yves Chibon 606ecb
                'csrf_token': csrf_token,
Pierre-Yves Chibon 606ecb
            }
Pierre-Yves Chibon 606ecb
            output = self.app.post(
Pierre-Yves Chibon 606ecb
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 606ecb
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 606ecb
            # Check the redirect
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 606ecb
            # Check the ordering
Pierre-Yves Chibon 606ecb
            self.assertTrue(
Pierre-Yves Chibon 606ecb
                output.data.find('High') < output.data.find('Normal'))
Pierre-Yves Chibon 606ecb
            self.assertTrue(
Pierre-Yves Chibon 606ecb
                output.data.find('Normal') < output.data.find('Low'))
Pierre-Yves Chibon 606ecb
            # Check the result of the action -- Priority recorded
Pierre-Yves Chibon 606ecb
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 606ecb
            self.assertEqual(
Pierre-Yves Chibon 606ecb
                repo.priorities,
Pierre-Yves Chibon 606ecb
                {u'': u'', u'1': u'High', u'2': u'Normal', u'3': u'Low'}
Pierre-Yves Chibon 606ecb
            )
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
            # Try setting the default priority
Pierre-Yves Chibon 606ecb
            data = {'priority': 'High', 'csrf_token': csrf_token}
Pierre-Yves Chibon 606ecb
            output = self.app.post(
Pierre-Yves Chibon 606ecb
                '/test/update/default_priority', data=data,
Pierre-Yves Chibon 606ecb
                follow_redirects=True)
Pierre-Yves Chibon 606ecb
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 606ecb
            # Check the redirect
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '\n                      Default priority set '
Pierre-Yves Chibon 606ecb
                'to High', output.data)
Pierre-Yves Chibon 606ecb
            # Check the result of the action -- default_priority no change
Pierre-Yves Chibon 606ecb
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 606ecb
            self.assertEqual(repo.default_priority, 'High')
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon 606ecb
            # Remove the Hight priority
Pierre-Yves Chibon 606ecb
            data = {
Pierre-Yves Chibon 606ecb
                'priority_weigth': [1, 2],
Pierre-Yves Chibon 606ecb
                'priority_title': ['Normal', 'Low'],
Pierre-Yves Chibon 606ecb
                'csrf_token': csrf_token,
Pierre-Yves Chibon 606ecb
            }
Pierre-Yves Chibon 606ecb
            output = self.app.post(
Pierre-Yves Chibon 606ecb
                '/test/update/priorities', data=data, follow_redirects=True)
Pierre-Yves Chibon 606ecb
            self.assertEqual(output.status_code, 200)
Pierre-Yves Chibon 606ecb
            # Check the redirect
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '<title>Settings - test - Pagure</title>', output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn('

Settings for test

', output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '\n                      Priorities updated',
Pierre-Yves Chibon 606ecb
                output.data)
Pierre-Yves Chibon 606ecb
            self.assertIn(
Pierre-Yves Chibon 606ecb
                '\n                      Default priority reset '
Pierre-Yves Chibon 606ecb
                'as it is no longer one of set priorities.',
Pierre-Yves Chibon 606ecb
                output.data)
Pierre-Yves Chibon 606ecb
            # Check the ordering
Pierre-Yves Chibon 606ecb
            self.assertTrue(
Pierre-Yves Chibon 606ecb
                output.data.find('Normal') < output.data.find('Low'))
Pierre-Yves Chibon 606ecb
            # Check the result of the action -- Priority recorded
Pierre-Yves Chibon 606ecb
            repo = pagure.get_authorized_project(self.session, 'test')
Pierre-Yves Chibon 606ecb
            self.assertEqual(
Pierre-Yves Chibon 606ecb
                repo.priorities,
Pierre-Yves Chibon 606ecb
                {u'': u'', u'1': u'Normal', u'2': u'Low'}
Pierre-Yves Chibon 606ecb
            )
Pierre-Yves Chibon 606ecb
            # Default priority is now None
Pierre-Yves Chibon 606ecb
            self.assertIsNone(repo.default_priority)
Pierre-Yves Chibon 606ecb
Pierre-Yves Chibon af88e9
Pierre-Yves Chibon af88e9
if __name__ == '__main__':
Pierre-Yves Chibon 393f31
    unittest.main(verbosity=2)