|
Pierre-Yves Chibon |
af88e9 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
"""
|
|
Pierre-Yves Chibon |
77bdcd |
(c) 2016-2018 - 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 |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
626417 |
|
|
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 |
73d120 |
sys.path.insert(
|
|
Pierre-Yves Chibon |
73d120 |
0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
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 |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@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)
|
|
Pierre-Yves Chibon |
73d120 |
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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/new_issue")
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertTrue(
|
|
Ryan Lerch |
7230c1 |
'New Issue\n'
|
|
Pierre-Yves Chibon |
73d120 |
in output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"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 |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
af88e9 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertNotIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@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)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
# Set some priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/new_issue")
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertTrue(
|
|
Ryan Lerch |
7230c1 |
'New Issue\n'
|
|
Pierre-Yves Chibon |
73d120 |
in output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
af88e9 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"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 |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
af88e9 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
af88e9 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
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)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Pierre-Yves Chibon |
3d1519 |
# Set some priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Pierre-Yves Chibon |
3d1519 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority_weigth": 1, "priority_title": "High"}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- None, no CSRF
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Pierre-Yves Chibon |
3d1519 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": 1,
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": "High",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(repo.priorities, {"": "", "1": "High"})
|
|
Pierre-Yves Chibon |
3d1519 |
|
|
Pierre-Yves Chibon |
3d1519 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Patrick Uiterwijk |
a764eb |
# Check the ordering
|
|
Patrick Uiterwijk |
a764eb |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("High") < output_text.find("Normal")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Patrick Uiterwijk |
a764eb |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("Normal") < output_text.find("Low")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
3d1519 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "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 |
73d120 |
"priority_weigth": [1, 2],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"Priorities weights and titles are " "not of the same length",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
b130e5 |
# Check the result of the action -- Priorities un-changed
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
3d1519 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "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 |
73d120 |
"priority_weigth": [1, 2, "c"],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Priorities weights must be numbers", output_text)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- Priorities un-changed
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
3d1519 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "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 |
73d120 |
"priority_weigth": [1, 2, 2],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Priority weight 2 is present 2 times", output_text)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- Priorities un-changed
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
3d1519 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "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 |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Normal"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
3d1519 |
}
|
|
Pierre-Yves Chibon |
3d1519 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the redirect
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Priority Normal is present 2 times", output_text)
|
|
Pierre-Yves Chibon |
3d1519 |
# Check the result of the action -- Priorities un-changed
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
3d1519 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
3d1519 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "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 |
73d120 |
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 |
73d120 |
output = self.app.post("/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 |
73d120 |
output = self.app.post("/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 |
73d120 |
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 |
73d120 |
user.username = "ralph"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.post("/test/update/priorities", data=data)
|
|
Pierre-Yves Chibon |
068320 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
068320 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@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)
|
|
Pierre-Yves Chibon |
73d120 |
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
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Set some priorities
|
|
Pierre-Yves Chibon |
7b3aee |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
7b3aee |
}
|
|
Pierre-Yves Chibon |
7b3aee |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(
|
|
Pierre-Yves Chibon |
7b3aee |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "Low"},
|
|
Pierre-Yves Chibon |
7b3aee |
)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Create an issue
|
|
Pierre-Yves Chibon |
7b3aee |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
7b3aee |
}
|
|
Pierre-Yves Chibon |
7b3aee |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
7b3aee |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Check that the ticket *does* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Reset the priorities
|
|
Pierre-Yves Chibon |
73d120 |
data = {"csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
7b3aee |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Check that the issue list renders fine
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issues")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
7b3aee |
# Check that the ticket *does not* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertNotIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
b130e5 |
# Check the result of the action -- Priority reset
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
7b3aee |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
7b3aee |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git")
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email")
|
|
Pierre-Yves Chibon |
138ab4 |
def test_reset_priorities_None(self, p_send_email, p_ugt):
|
|
Pierre-Yves Chibon |
138ab4 |
""" Test resetting the priorities of a repo. """
|
|
Pierre-Yves Chibon |
138ab4 |
p_send_email.return_value = True
|
|
Pierre-Yves Chibon |
138ab4 |
p_ugt.return_value = True
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Start from scrach on priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set some priorities
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
138ab4 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "Low"},
|
|
Pierre-Yves Chibon |
138ab4 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Create an issue
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the ticket *does* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Reset the priorities
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": None, "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the issue list renders fine
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issues")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the ticket *does not* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertNotIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
138ab4 |
def test_set_priority_1_and_back(self):
|
|
Pierre-Yves Chibon |
138ab4 |
""" Test setting the priority of a ticket to 1. """
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Start from scrach on priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set some priorities
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [-1, 0, 1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": [
|
|
Pierre-Yves Chibon |
73d120 |
"Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"High",
|
|
Pierre-Yves Chibon |
73d120 |
"Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"Low",
|
|
Pierre-Yves Chibon |
73d120 |
],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
138ab4 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{
|
|
Pierre-Yves Chibon |
73d120 |
"": "",
|
|
Pierre-Yves Chibon |
73d120 |
"-1": "Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"0": "Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"1": "High",
|
|
Pierre-Yves Chibon |
73d120 |
"2": "Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"3": "Low",
|
|
Pierre-Yves Chibon |
73d120 |
},
|
|
Pierre-Yves Chibon |
138ab4 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Create an issue
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the ticket *does* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set the priority to High
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "1", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/issue/1/update", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option selected="" value="1">High</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Reset the priority
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/issue/1/update", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
138ab4 |
def test_set_priority_0(self):
|
|
Pierre-Yves Chibon |
138ab4 |
""" Test setting the priority of a ticket to 0. """
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Start from scrach on priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set some priorities
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [-1, 0, 1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": [
|
|
Pierre-Yves Chibon |
73d120 |
"Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"High",
|
|
Pierre-Yves Chibon |
73d120 |
"Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"Low",
|
|
Pierre-Yves Chibon |
73d120 |
],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
138ab4 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{
|
|
Pierre-Yves Chibon |
73d120 |
"": "",
|
|
Pierre-Yves Chibon |
73d120 |
"-1": "Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"0": "Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"1": "High",
|
|
Pierre-Yves Chibon |
73d120 |
"2": "Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"3": "Low",
|
|
Pierre-Yves Chibon |
73d120 |
},
|
|
Pierre-Yves Chibon |
138ab4 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Create an issue
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the ticket *does* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set the priority to Urgent
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "0", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/issue/1/update", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option selected="" value="0">Urgent</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
138ab4 |
def test_set_priority_minus1(self):
|
|
Pierre-Yves Chibon |
138ab4 |
""" Test setting the priority of a ticket to -1. """
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Start from scrach on priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(repo.priorities, {})
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Get the CSRF token
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/settings")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Aurélien Bompard |
626417 |
csrf_token = output_text.split(
|
|
Pierre-Yves Chibon |
73d120 |
'name="csrf_token" type="hidden" value="'
|
|
Pierre-Yves Chibon |
73d120 |
)[1].split('">')[0]
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set some priorities
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"priority_weigth": [-1, 0, 1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": [
|
|
Pierre-Yves Chibon |
73d120 |
"Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"High",
|
|
Pierre-Yves Chibon |
73d120 |
"Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"Low",
|
|
Pierre-Yves Chibon |
73d120 |
],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query._get_project(self.session, "test")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
138ab4 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{
|
|
Pierre-Yves Chibon |
73d120 |
"": "",
|
|
Pierre-Yves Chibon |
73d120 |
"-1": "Sky Falling",
|
|
Pierre-Yves Chibon |
73d120 |
"0": "Urgent",
|
|
Pierre-Yves Chibon |
73d120 |
"1": "High",
|
|
Pierre-Yves Chibon |
73d120 |
"2": "Normal",
|
|
Pierre-Yves Chibon |
73d120 |
"3": "Low",
|
|
Pierre-Yves Chibon |
73d120 |
},
|
|
Pierre-Yves Chibon |
138ab4 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Create an issue
|
|
Pierre-Yves Chibon |
138ab4 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
138ab4 |
}
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Check that the ticket *does* have priorities
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.get("/test/issue/1")
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
# Set the priority to Sky Falling
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "-1", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
138ab4 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/issue/1/update", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
138ab4 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
138ab4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
'<option selected="" value="-1">Sky Falling</option>', output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="0">Urgent</option>', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<option value="1">High</option>', output_text)
|
|
Pierre-Yves Chibon |
138ab4 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@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 |
73d120 |
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 |
73d120 |
repo = pagure.lib.query.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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, 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 |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
dff667 |
}
|
|
Pierre-Yves Chibon |
dff667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the redirect
|
|
Pierre-Yves Chibon |
dff667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the ordering
|
|
Pierre-Yves Chibon |
dff667 |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("High") < output_text.find("Normal")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("Normal") < output_text.find("Low")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
dff667 |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "Low"},
|
|
Pierre-Yves Chibon |
dff667 |
)
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
dff667 |
# Try setting the default priority -- no csrf
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "High"}
|
|
Pierre-Yves Chibon |
dff667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/default_priority",
|
|
Pierre-Yves Chibon |
73d120 |
data=data,
|
|
Pierre-Yves Chibon |
73d120 |
follow_redirects=True,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the redirect
|
|
Pierre-Yves Chibon |
dff667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the result of the action -- default_priority no change
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
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 |
73d120 |
data = {"priority": "High", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
dff667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/default_priority",
|
|
Pierre-Yves Chibon |
73d120 |
data=data,
|
|
Pierre-Yves Chibon |
73d120 |
follow_redirects=True,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the redirect
|
|
Pierre-Yves Chibon |
dff667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Default priority set " "to High", output_text)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the result of the action -- default_priority no change
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(repo.default_priority, "High")
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
dff667 |
# Try setting a wrong default priority
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "Smooth", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
dff667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/default_priority",
|
|
Pierre-Yves Chibon |
73d120 |
data=data,
|
|
Pierre-Yves Chibon |
73d120 |
follow_redirects=True,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the redirect
|
|
Pierre-Yves Chibon |
dff667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the result of the action -- default_priority no change
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(repo.default_priority, "High")
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
dff667 |
# reset the default priority
|
|
Pierre-Yves Chibon |
73d120 |
data = {"csrf_token": csrf_token, "priority": ""}
|
|
Pierre-Yves Chibon |
dff667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/default_priority",
|
|
Pierre-Yves Chibon |
73d120 |
data=data,
|
|
Pierre-Yves Chibon |
73d120 |
follow_redirects=True,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the redirect
|
|
Pierre-Yves Chibon |
dff667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Default priority reset", output_text)
|
|
Pierre-Yves Chibon |
dff667 |
# Check the result of the action -- default_priority no change
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
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 |
73d120 |
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 |
73d120 |
output = self.app.post("/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 |
73d120 |
output = self.app.post("/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 |
73d120 |
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 |
73d120 |
user.username = "ralph"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
73d120 |
output = self.app.post("/test/update/default_priority", data=data)
|
|
Pierre-Yves Chibon |
dff667 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
dff667 |
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@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 |
73d120 |
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 |
73d120 |
repo = pagure.lib.query.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 |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, 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 |
73d120 |
"priority_weigth": [1, 2, 3],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["High", "Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
606ecb |
}
|
|
Pierre-Yves Chibon |
606ecb |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the redirect
|
|
Pierre-Yves Chibon |
606ecb |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the ordering
|
|
Pierre-Yves Chibon |
606ecb |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("High") < output_text.find("Normal")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("Normal") < output_text.find("Low")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertEqual(
|
|
Pierre-Yves Chibon |
606ecb |
repo.priorities,
|
|
Pierre-Yves Chibon |
73d120 |
{"": "", "1": "High", "2": "Normal", "3": "Low"},
|
|
Pierre-Yves Chibon |
606ecb |
)
|
|
Pierre-Yves Chibon |
606ecb |
|
|
Pierre-Yves Chibon |
606ecb |
# Try setting the default priority
|
|
Pierre-Yves Chibon |
73d120 |
data = {"priority": "High", "csrf_token": csrf_token}
|
|
Pierre-Yves Chibon |
606ecb |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/default_priority",
|
|
Pierre-Yves Chibon |
73d120 |
data=data,
|
|
Pierre-Yves Chibon |
73d120 |
follow_redirects=True,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the redirect
|
|
Pierre-Yves Chibon |
606ecb |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Default priority set " "to High", output_text)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the result of the action -- default_priority no change
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
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 |
73d120 |
"priority_weigth": [1, 2],
|
|
Pierre-Yves Chibon |
73d120 |
"priority_title": ["Normal", "Low"],
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
606ecb |
}
|
|
Pierre-Yves Chibon |
606ecb |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/update/priorities", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the redirect
|
|
Pierre-Yves Chibon |
606ecb |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Settings - test - Pagure</title>", output_text
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
77bdcd |
self.assertIn(
|
|
Pierre-Yves Chibon |
77bdcd |
''
|
|
Pierre-Yves Chibon |
73d120 |
"Project Settings\n",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
73d120 |
self.assertIn("Priorities updated", output_text)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"Default priority reset "
|
|
Pierre-Yves Chibon |
73d120 |
"as it is no longer one of set priorities.",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the ordering
|
|
Pierre-Yves Chibon |
606ecb |
self.assertTrue(
|
|
Pierre-Yves Chibon |
73d120 |
output_text.find("Normal") < output_text.find("Low")
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
# Check the result of the action -- Priority recorded
|
|
Aurélien Bompard |
13bcde |
self.session.commit()
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(
|
|
Pierre-Yves Chibon |
73d120 |
self.session, "test"
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
606ecb |
self.assertEqual(
|
|
Pierre-Yves Chibon |
73d120 |
repo.priorities, {"": "", "1": "Normal", "2": "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 |
73d120 |
@patch("pagure.lib.git.update_git", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
73d120 |
@patch("pagure.lib.notify.send_email", MagicMock(return_value=True))
|
|
Pierre-Yves Chibon |
521996 |
def test_default_priority_on_new_ticket(self):
|
|
Pierre-Yves Chibon |
521996 |
""" Test updating the default priority of a repo. """
|
|
Pierre-Yves Chibon |
521996 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
73d120 |
tests.create_projects_git(os.path.join(self.path, "repos"), bare=True)
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
521996 |
# Set some priority and the default one
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
repo.priorities = {"1": "High", "2": "Normal"}
|
|
Pierre-Yves Chibon |
73d120 |
repo.default_priority = "Normal"
|
|
Pierre-Yves Chibon |
521996 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
521996 |
self.session.commit()
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
521996 |
# Check the default priorities
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(repo.priorities, {"1": "High", "2": "Normal"})
|
|
Pierre-Yves Chibon |
73d120 |
self.assertEqual(repo.default_priority, "Normal")
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
521996 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
73d120 |
user.username = "pingou"
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
521996 |
csrf_token = self.get_csrf()
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
521996 |
data = {
|
|
Pierre-Yves Chibon |
73d120 |
"title": "Test issue",
|
|
Pierre-Yves Chibon |
73d120 |
"issue_content": "We really should improve on this issue",
|
|
Pierre-Yves Chibon |
73d120 |
"status": "Open",
|
|
Pierre-Yves Chibon |
73d120 |
"csrf_token": csrf_token,
|
|
Pierre-Yves Chibon |
521996 |
}
|
|
Pierre-Yves Chibon |
521996 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
73d120 |
"/test/new_issue", data=data, follow_redirects=True
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
521996 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
521996 |
self.assertIn(
|
|
Pierre-Yves Chibon |
73d120 |
"<title>Issue #1: Test issue - test - Pagure</title>",
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
521996 |
self.assertIn(
|
|
Ryan Lerch |
e85d33 |
'
|
|
Pierre-Yves Chibon |
521996 |
'href="/test/issue/1/edit" title="Edit this issue">',
|
|
Pierre-Yves Chibon |
73d120 |
output_text,
|
|
Pierre-Yves Chibon |
73d120 |
)
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
73d120 |
repo = pagure.lib.query.get_authorized_project(self.session, "test")
|
|
Pierre-Yves Chibon |
521996 |
self.assertEqual(len(repo.issues), 1)
|
|
Pierre-Yves Chibon |
521996 |
self.assertEqual(repo.issues[0].priority, 2)
|
|
Pierre-Yves Chibon |
521996 |
|
|
Pierre-Yves Chibon |
af88e9 |
|
|
Pierre-Yves Chibon |
73d120 |
if __name__ == "__main__":
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|