|
Pierre-Yves Chibon |
9347b5 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
"""
|
|
Pierre-Yves Chibon |
9347b5 |
(c) 2015 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
Authors:
|
|
Pierre-Yves Chibon |
9347b5 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
"""
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
__requires__ = ['SQLAlchemy >= 0.8']
|
|
Pierre-Yves Chibon |
9347b5 |
import pkg_resources
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
import json
|
|
Pierre-Yves Chibon |
9347b5 |
import unittest
|
|
Pierre-Yves Chibon |
9347b5 |
import shutil
|
|
Pierre-Yves Chibon |
9347b5 |
import sys
|
|
Pierre-Yves Chibon |
9347b5 |
import tempfile
|
|
Pierre-Yves Chibon |
9347b5 |
import os
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
import pygit2
|
|
Pierre-Yves Chibon |
9347b5 |
from mock import patch
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Pierre-Yves Chibon |
9347b5 |
os.path.abspath(__file__)), '..'))
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
import pagure.lib
|
|
Pierre-Yves Chibon |
9347b5 |
import tests
|
|
Pierre-Yves Chibon |
27a73d |
from pagure.lib.repo import PagureRepo
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
edfd4c |
def _get_commits(output):
|
|
Pierre-Yves Chibon |
edfd4c |
''' Returns the commits message in the output. All commits must have
|
|
Pierre-Yves Chibon |
edfd4c |
been made by `Alice Author` or `PY C` to be found.
|
|
Pierre-Yves Chibon |
edfd4c |
'''
|
|
Pierre-Yves Chibon |
edfd4c |
commits = []
|
|
Pierre-Yves Chibon |
edfd4c |
save = False
|
|
Pierre-Yves Chibon |
edfd4c |
cnt = 0
|
|
Pierre-Yves Chibon |
edfd4c |
for row in output.split('\n'):
|
|
Pierre-Yves Chibon |
7c68f8 |
if row.strip() in ['Alice Author', 'Alice Äuthòr', 'PY C']:
|
|
Pierre-Yves Chibon |
edfd4c |
save = True
|
|
Pierre-Yves Chibon |
edfd4c |
if save:
|
|
Pierre-Yves Chibon |
edfd4c |
cnt += 1
|
|
Pierre-Yves Chibon |
edfd4c |
if cnt == 7:
|
|
Pierre-Yves Chibon |
edfd4c |
commits.append(row.strip())
|
|
Pierre-Yves Chibon |
edfd4c |
save = False
|
|
Pierre-Yves Chibon |
edfd4c |
cnt = 0
|
|
Pierre-Yves Chibon |
edfd4c |
return commits
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
9347b5 |
class PagureFlaskForktests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
9347b5 |
""" Tests for flask fork controller of pagure """
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
def setUp(self):
|
|
Pierre-Yves Chibon |
9347b5 |
""" Set up the environnment, ran before every tests. """
|
|
Pierre-Yves Chibon |
9347b5 |
super(PagureFlaskForktests, self).setUp()
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.APP.config['TESTING'] = True
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.SESSION = self.session
|
|
Pierre-Yves Chibon |
005063 |
pagure.lib.SESSION = self.session
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.ui.SESSION = self.session
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.ui.app.SESSION = self.session
|
|
Pierre-Yves Chibon |
f4b1a9 |
pagure.ui.filters.SESSION = self.session
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.ui.fork.SESSION = self.session
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.ui.repo.SESSION = self.session
|
|
Pierre-Yves Chibon |
8dec5e |
pagure.ui.issues.SESSION = self.session
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
ae1f3a |
pagure.APP.config['GIT_FOLDER'] = os.path.join(tests.HERE, 'repos')
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.APP.config['TICKETS_FOLDER'] = os.path.join(
|
|
Pierre-Yves Chibon |
9347b5 |
tests.HERE, 'tickets')
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.APP.config['DOCS_FOLDER'] = os.path.join(
|
|
Pierre-Yves Chibon |
9347b5 |
tests.HERE, 'docs')
|
|
Pierre-Yves Chibon |
9347b5 |
pagure.APP.config['REQUESTS_FOLDER'] = os.path.join(
|
|
Pierre-Yves Chibon |
9347b5 |
tests.HERE, 'requests')
|
|
Pierre-Yves Chibon |
9347b5 |
self.app = pagure.APP.test_client()
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
224b96 |
def set_up_git_repo(
|
|
Pierre-Yves Chibon |
224b96 |
self, new_project=None, branch_from='feature', mtype='FF'):
|
|
Pierre-Yves Chibon |
9347b5 |
""" Set up the git repo and create the corresponding PullRequest
|
|
Pierre-Yves Chibon |
9347b5 |
object.
|
|
Pierre-Yves Chibon |
9347b5 |
"""
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
ae1f3a |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
9347b5 |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
eaaf26 |
repopath = os.path.join(newpath, 'test')
|
|
Pierre-Yves Chibon |
eaaf26 |
clone_repo = pygit2.clone_repository(gitrepo, repopath)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Create a file in that git repo
|
|
Pierre-Yves Chibon |
eaaf26 |
with open(os.path.join(repopath, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
9347b5 |
stream.write('foo\n bar')
|
|
Pierre-Yves Chibon |
9347b5 |
clone_repo.index.add('sources')
|
|
Pierre-Yves Chibon |
9347b5 |
clone_repo.index.write()
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Commits the files added
|
|
Pierre-Yves Chibon |
9347b5 |
tree = clone_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
9347b5 |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
9347b5 |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
9347b5 |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
9347b5 |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
9347b5 |
clone_repo.create_commit(
|
|
Pierre-Yves Chibon |
9347b5 |
'refs/heads/master', # the name of the reference to update
|
|
Pierre-Yves Chibon |
9347b5 |
author,
|
|
Pierre-Yves Chibon |
9347b5 |
committer,
|
|
Pierre-Yves Chibon |
9347b5 |
'Add sources file for testing',
|
|
Pierre-Yves Chibon |
9347b5 |
# binary string representing the tree object ID
|
|
Pierre-Yves Chibon |
9347b5 |
tree,
|
|
Pierre-Yves Chibon |
9347b5 |
# list of binary strings representing parents of the new commit
|
|
Pierre-Yves Chibon |
9347b5 |
[]
|
|
Pierre-Yves Chibon |
9347b5 |
)
|
|
Pierre-Yves Chibon |
9347b5 |
refname = 'refs/heads/master:refs/heads/master'
|
|
Pierre-Yves Chibon |
9347b5 |
ori_remote = clone_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
first_commit = repo.revparse_single('HEAD')
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
224b96 |
if mtype == 'merge':
|
|
Pierre-Yves Chibon |
eaaf26 |
with open(os.path.join(repopath, '.gitignore'), 'w') as stream:
|
|
Pierre-Yves Chibon |
224b96 |
stream.write('*~')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.index.add('.gitignore')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.index.write()
|
|
Pierre-Yves Chibon |
224b96 |
|
|
Pierre-Yves Chibon |
224b96 |
# Commits the files added
|
|
Pierre-Yves Chibon |
224b96 |
tree = clone_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
224b96 |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
7c68f8 |
'Alice Äuthòr', 'alice@äuthòrs.tld')
|
|
Pierre-Yves Chibon |
224b96 |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
7c68f8 |
'Cecil Cõmmîttër', 'cecil@cõmmîttërs.tld')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.create_commit(
|
|
Pierre-Yves Chibon |
224b96 |
'refs/heads/master',
|
|
Pierre-Yves Chibon |
224b96 |
author,
|
|
Pierre-Yves Chibon |
224b96 |
committer,
|
|
Pierre-Yves Chibon |
224b96 |
'Add .gitignore file for testing',
|
|
Pierre-Yves Chibon |
224b96 |
# binary string representing the tree object ID
|
|
Pierre-Yves Chibon |
224b96 |
tree,
|
|
Pierre-Yves Chibon |
224b96 |
# list of binary strings representing parents of the new commit
|
|
Pierre-Yves Chibon |
224b96 |
[first_commit.oid.hex]
|
|
Pierre-Yves Chibon |
224b96 |
)
|
|
Pierre-Yves Chibon |
224b96 |
refname = 'refs/heads/master:refs/heads/master'
|
|
Pierre-Yves Chibon |
224b96 |
ori_remote = clone_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
224b96 |
|
|
Pierre-Yves Chibon |
224b96 |
if mtype == 'conflicts':
|
|
Pierre-Yves Chibon |
eaaf26 |
with open(os.path.join(repopath, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
224b96 |
stream.write('foo\n bar\nbaz')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.index.add('sources')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.index.write()
|
|
Pierre-Yves Chibon |
224b96 |
|
|
Pierre-Yves Chibon |
224b96 |
# Commits the files added
|
|
Pierre-Yves Chibon |
224b96 |
tree = clone_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
224b96 |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
224b96 |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
224b96 |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
224b96 |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
224b96 |
clone_repo.create_commit(
|
|
Pierre-Yves Chibon |
224b96 |
'refs/heads/master',
|
|
Pierre-Yves Chibon |
224b96 |
author,
|
|
Pierre-Yves Chibon |
224b96 |
committer,
|
|
Pierre-Yves Chibon |
224b96 |
'Add sources conflicting',
|
|
Pierre-Yves Chibon |
224b96 |
# binary string representing the tree object ID
|
|
Pierre-Yves Chibon |
224b96 |
tree,
|
|
Pierre-Yves Chibon |
224b96 |
# list of binary strings representing parents of the new commit
|
|
Pierre-Yves Chibon |
224b96 |
[first_commit.oid.hex]
|
|
Pierre-Yves Chibon |
224b96 |
)
|
|
Pierre-Yves Chibon |
224b96 |
refname = 'refs/heads/master:refs/heads/master'
|
|
Pierre-Yves Chibon |
224b96 |
ori_remote = clone_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
224b96 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Set the second repo
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
eaaf26 |
new_gitrepo = repopath
|
|
Pierre-Yves Chibon |
9347b5 |
if new_project:
|
|
Pierre-Yves Chibon |
9347b5 |
# Create a new git repo to play with
|
|
Pierre-Yves Chibon |
eaaf26 |
new_gitrepo = os.path.join(newpath, new_project.fullname)
|
|
Pierre-Yves Chibon |
9347b5 |
if not os.path.exists(new_gitrepo):
|
|
Pierre-Yves Chibon |
9347b5 |
os.makedirs(new_gitrepo)
|
|
Pierre-Yves Chibon |
9347b5 |
new_repo = pygit2.clone_repository(gitrepo, new_gitrepo)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
repo = pygit2.Repository(new_gitrepo)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
224b96 |
if mtype != 'nochanges':
|
|
Pierre-Yves Chibon |
224b96 |
# Edit the sources file again
|
|
Pierre-Yves Chibon |
224b96 |
with open(os.path.join(new_gitrepo, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
224b96 |
stream.write('foo\n bar\nbaz\n boose')
|
|
Pierre-Yves Chibon |
224b96 |
repo.index.add('sources')
|
|
Pierre-Yves Chibon |
224b96 |
repo.index.write()
|
|
Pierre-Yves Chibon |
224b96 |
|
|
Pierre-Yves Chibon |
224b96 |
# Commits the files added
|
|
Pierre-Yves Chibon |
224b96 |
tree = repo.index.write_tree()
|
|
Pierre-Yves Chibon |
224b96 |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
224b96 |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
224b96 |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
224b96 |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
224b96 |
repo.create_commit(
|
|
Pierre-Yves Chibon |
224b96 |
'refs/heads/%s' % branch_from,
|
|
Pierre-Yves Chibon |
224b96 |
author,
|
|
Pierre-Yves Chibon |
224b96 |
committer,
|
|
Pierre-Yves Chibon |
224b96 |
'A commit on branch %s' % branch_from,
|
|
Pierre-Yves Chibon |
224b96 |
tree,
|
|
Pierre-Yves Chibon |
224b96 |
[first_commit.oid.hex]
|
|
Pierre-Yves Chibon |
224b96 |
)
|
|
Pierre-Yves Chibon |
eaaf26 |
refname = 'refs/heads/%s' % (branch_from)
|
|
Pierre-Yves Chibon |
eaaf26 |
ori_remote = repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Create a PR for these changes
|
|
Pierre-Yves Chibon |
9347b5 |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
f9c5f9 |
req = pagure.lib.new_pull_request(
|
|
Pierre-Yves Chibon |
9347b5 |
session=self.session,
|
|
Pierre-Yves Chibon |
9347b5 |
repo_from=project,
|
|
Pierre-Yves Chibon |
9347b5 |
branch_from=branch_from,
|
|
Pierre-Yves Chibon |
9347b5 |
repo_to=project,
|
|
Pierre-Yves Chibon |
9347b5 |
branch_to='master',
|
|
Pierre-Yves Chibon |
9347b5 |
title='PR from the %s branch' % branch_from,
|
|
Pierre-Yves Chibon |
9347b5 |
user='pingou',
|
|
Pierre-Yves Chibon |
9347b5 |
requestfolder=None,
|
|
Pierre-Yves Chibon |
9347b5 |
)
|
|
Pierre-Yves Chibon |
9347b5 |
self.session.commit()
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.id, 1)
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.title, 'PR from the %s branch' % branch_from)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
5d6e3d |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
5d6e3d |
|
|
Pierre-Yves Chibon |
9347b5 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
9347b5 |
def test_request_pull(self, send_email):
|
|
Pierre-Yves Chibon |
9347b5 |
""" Test the request_pull endpoint. """
|
|
Pierre-Yves Chibon |
9347b5 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
9347b5 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
9347b5 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Non-existant project
|
|
Pierre-Yves Chibon |
9347b5 |
output = self.app.get('/foobar/pull-request/1')
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# Project has no PR
|
|
Pierre-Yves Chibon |
9347b5 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
self.set_up_git_repo(new_project=None, branch_from='feature')
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertEqual(len(project.requests), 1)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
9347b5 |
# View the pull-request
|
|
Pierre-Yves Chibon |
9347b5 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
9347b5 |
self.assertIn(
|
|
Pierre-Yves Chibon |
15a1bc |
'title="View file as of 2a552b">sources', output.data)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
502b7a |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
502b7a |
def test_merge_request_pull_FF(self, send_email):
|
|
Pierre-Yves Chibon |
8911da |
""" Test the merge_request_pull endpoint with a FF PR. """
|
|
Pierre-Yves Chibon |
502b7a |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
self.test_request_pull()
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
502b7a |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
502b7a |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# No CSRF
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data={}, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
99b438 |
self.assertIn(
|
|
Pierre-Yves Chibon |
15a1bc |
'title="View file as of 2a552b">sources', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Wrong project
|
|
Pierre-Yves Chibon |
502b7a |
data = {
|
|
Pierre-Yves Chibon |
502b7a |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
502b7a |
}
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/foobar/pull-request/100/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Wrong project
|
|
Pierre-Yves Chibon |
502b7a |
data = {
|
|
Pierre-Yves Chibon |
502b7a |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
502b7a |
}
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
502b7a |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Wrong request id
|
|
Pierre-Yves Chibon |
502b7a |
data = {
|
|
Pierre-Yves Chibon |
502b7a |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
502b7a |
}
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/100/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
502b7a |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
502b7a |
settings = repo.settings
|
|
Pierre-Yves Chibon |
502b7a |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
502b7a |
repo.settings = settings
|
|
Pierre-Yves Chibon |
502b7a |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
502b7a |
self.session.commit()
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Pull-request disabled
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Project w pull-request but only assignee can merge
|
|
Pierre-Yves Chibon |
502b7a |
settings['pull_requests'] = True
|
|
Pierre-Yves Chibon |
502b7a |
settings['Only_assignee_can_merge_pull-request'] = True
|
|
Pierre-Yves Chibon |
502b7a |
repo.settings = settings
|
|
Pierre-Yves Chibon |
502b7a |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
502b7a |
self.session.commit()
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
99b438 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n This request must be '
|
|
Pierre-Yves Chibon |
19b2ae |
'assigned to be merged', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# PR assigned but not to this user
|
|
Pierre-Yves Chibon |
502b7a |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
502b7a |
req = repo.requests[0]
|
|
Pierre-Yves Chibon |
502b7a |
req.assignee_id = 2
|
|
Pierre-Yves Chibon |
502b7a |
self.session.add(req)
|
|
Pierre-Yves Chibon |
502b7a |
self.session.commit()
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Only the assignee can '
|
|
Pierre-Yves Chibon |
19b2ae |
'merge this review', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Project w/ minimal PR score
|
|
Pierre-Yves Chibon |
502b7a |
settings['Only_assignee_can_merge_pull-request'] = False
|
|
Pierre-Yves Chibon |
502b7a |
settings['Minimum_score_to_merge_pull-request'] = 2
|
|
Pierre-Yves Chibon |
502b7a |
repo.settings = settings
|
|
Pierre-Yves Chibon |
502b7a |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
502b7a |
self.session.commit()
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n This request does not '
|
|
Pierre-Yves Chibon |
19b2ae |
'have the minimum review score necessary to be merged',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
502b7a |
# Merge
|
|
Pierre-Yves Chibon |
502b7a |
settings['Minimum_score_to_merge_pull-request'] = -1
|
|
Pierre-Yves Chibon |
502b7a |
repo.settings = settings
|
|
Pierre-Yves Chibon |
502b7a |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
502b7a |
self.session.commit()
|
|
Pierre-Yves Chibon |
502b7a |
output = self.app.post(
|
|
Pierre-Yves Chibon |
502b7a |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
502b7a |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
502b7a |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Changes merged!',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'A commit on branch feature', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'Merge #1 `PR from the feature branch`', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
# Ensure we have the new commit
|
|
Pierre-Yves Chibon |
edfd4c |
commits = _get_commits(output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(
|
|
Pierre-Yves Chibon |
edfd4c |
commits,
|
|
Pierre-Yves Chibon |
edfd4c |
[
|
|
Pierre-Yves Chibon |
edfd4c |
'A commit on branch feature',
|
|
Pierre-Yves Chibon |
edfd4c |
'Add sources file for testing'
|
|
Pierre-Yves Chibon |
edfd4c |
]
|
|
Pierre-Yves Chibon |
edfd4c |
)
|
|
Pierre-Yves Chibon |
502b7a |
|
|
Pierre-Yves Chibon |
21dd34 |
# Check if the closing notification was added
|
|
Pierre-Yves Chibon |
21dd34 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
21dd34 |
self.assertIn(
|
|
Pierre-Yves Chibon |
be62f6 |
'<small>Pull-Request has been merged by pingou </small>',
|
|
Pierre-Yves Chibon |
be62f6 |
output.data)
|
|
Pierre-Yves Chibon |
21dd34 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
4ce7b3 |
def test_merge_request_pull_merge(self, send_email):
|
|
Pierre-Yves Chibon |
4ce7b3 |
""" Test the merge_request_pull endpoint with a merge PR. """
|
|
Pierre-Yves Chibon |
4ce7b3 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
4ce7b3 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
4ce7b3 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
4ce7b3 |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
4ce7b3 |
new_project=None, branch_from='feature', mtype='merge')
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
4ce7b3 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
4ce7b3 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
4ce7b3 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
4ce7b3 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
4ce7b3 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
data = {
|
|
Pierre-Yves Chibon |
4ce7b3 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
4ce7b3 |
}
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
4ce7b3 |
# Merge
|
|
Pierre-Yves Chibon |
4ce7b3 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
4ce7b3 |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
4ce7b3 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
4ce7b3 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4ce7b3 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
4ce7b3 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Changes merged!',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
4ce7b3 |
|
|
Pierre-Yves Chibon |
21dd34 |
# Check if the closing notification was added
|
|
Pierre-Yves Chibon |
21dd34 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
21dd34 |
self.assertIn(
|
|
Pierre-Yves Chibon |
be62f6 |
'<small>Pull-Request has been merged by pingou </small>',
|
|
Pierre-Yves Chibon |
be62f6 |
output.data)
|
|
Pierre-Yves Chibon |
21dd34 |
|
|
Pierre-Yves Chibon |
fb36e7 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
fb36e7 |
def test_merge_request_pull_conflicts(self, send_email):
|
|
Pierre-Yves Chibon |
fb36e7 |
""" Test the merge_request_pull endpoint with a conflicting PR. """
|
|
Pierre-Yves Chibon |
fb36e7 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
fb36e7 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
fb36e7 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
fb36e7 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
fb36e7 |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
fb36e7 |
new_project=None, branch_from='feature', mtype='conflicts')
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
fb36e7 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
fb36e7 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
fb36e7 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
fb36e7 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
fb36e7 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
fb36e7 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
fb36e7 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
fb36e7 |
data = {
|
|
Pierre-Yves Chibon |
fb36e7 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
fb36e7 |
}
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
fb36e7 |
# Merge conflicts
|
|
Pierre-Yves Chibon |
fb36e7 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
fb36e7 |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
fb36e7 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fb36e7 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
fb36e7 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Merge conflicts!',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
fb36e7 |
|
|
Pierre-Yves Chibon |
51d667 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
51d667 |
def test_merge_request_pull_nochange(self, send_email):
|
|
Pierre-Yves Chibon |
51d667 |
""" Test the merge_request_pull endpoint. """
|
|
Pierre-Yves Chibon |
51d667 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
51d667 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
51d667 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
51d667 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
51d667 |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
51d667 |
new_project=None, branch_from='master', mtype='nochanges')
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
51d667 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
51d667 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
51d667 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
51d667 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
51d667 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
51d667 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
51d667 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
51d667 |
data = {
|
|
Pierre-Yves Chibon |
51d667 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
51d667 |
}
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
51d667 |
# Nothing to merge
|
|
Pierre-Yves Chibon |
51d667 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
51d667 |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
51d667 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
51d667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' Merged',
|
|
Pierre-Yves Chibon |
137f65 |
output.data)
|
|
Pierre-Yves Chibon |
51d667 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Nothing to do, changes '
|
|
Pierre-Yves Chibon |
19b2ae |
'were already merged', output.data)
|
|
Pierre-Yves Chibon |
51d667 |
|
|
Pierre-Yves Chibon |
21dd34 |
# Check if the closing notification was added
|
|
Pierre-Yves Chibon |
21dd34 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
21dd34 |
self.assertIn(
|
|
Pierre-Yves Chibon |
be62f6 |
'<small>Pull-Request has been merged by pingou </small>',
|
|
Pierre-Yves Chibon |
be62f6 |
output.data)
|
|
Pierre-Yves Chibon |
21dd34 |
|
|
Pierre-Yves Chibon |
21924a |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
21924a |
def test_request_pull_close(self, send_email):
|
|
Pierre-Yves Chibon |
21924a |
""" Test the request_pull endpoint with a closed PR. """
|
|
Pierre-Yves Chibon |
21924a |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
21924a |
|
|
Pierre-Yves Chibon |
21924a |
self.test_merge_request_pull_FF()
|
|
Pierre-Yves Chibon |
21924a |
|
|
Pierre-Yves Chibon |
21924a |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
21924a |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
21924a |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' ', output.data)
|
|
Pierre-Yves Chibon |
137f65 |
self.assertIn('Merged by\n', output.data)
|
|
Pierre-Yves Chibon |
21924a |
self.assertIn(
|
|
Pierre-Yves Chibon |
15a1bc |
'title="View file as of 2a552b">sources', output.data)
|
|
Pierre-Yves Chibon |
21924a |
|
|
Pierre-Yves Chibon |
c19e35 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
c19e35 |
def test_request_pull_disabled(self, send_email):
|
|
Pierre-Yves Chibon |
c19e35 |
""" Test the request_pull endpoint with PR disabled. """
|
|
Pierre-Yves Chibon |
c19e35 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
c19e35 |
|
|
Pierre-Yves Chibon |
c19e35 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
c19e35 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
c19e35 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
c19e35 |
self.set_up_git_repo(new_project=None, branch_from='feature')
|
|
Pierre-Yves Chibon |
c19e35 |
|
|
Pierre-Yves Chibon |
c19e35 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
c19e35 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
c19e35 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
c19e35 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
c19e35 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
c19e35 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
c19e35 |
self.session.commit()
|
|
Pierre-Yves Chibon |
c19e35 |
|
|
Pierre-Yves Chibon |
c19e35 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
c19e35 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
c19e35 |
|
|
Pierre-Yves Chibon |
cbbc1c |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
cbbc1c |
def test_request_pull_empty_repo(self, send_email):
|
|
Pierre-Yves Chibon |
ee247e |
""" Test the request_pull endpoint against an empty repo. """
|
|
Pierre-Yves Chibon |
cbbc1c |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
cbbc1c |
item = pagure.lib.model.Project(
|
|
Pierre-Yves Chibon |
cbbc1c |
user_id=2, # foo
|
|
Pierre-Yves Chibon |
cbbc1c |
name='test',
|
|
Pierre-Yves Chibon |
cbbc1c |
description='test project #1',
|
|
Pierre-Yves Chibon |
cbbc1c |
hook_token='aaabbb',
|
|
Pierre-Yves Chibon |
cbbc1c |
parent_id=1,
|
|
Pierre-Yves Chibon |
cbbc1c |
)
|
|
Pierre-Yves Chibon |
cbbc1c |
self.session.add(item)
|
|
Pierre-Yves Chibon |
cbbc1c |
self.session.commit()
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
cbbc1c |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
cbbc1c |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
5bf6f1 |
os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True)
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
cbbc1c |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
cbbc1c |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
cbbc1c |
os.makedirs(gitrepo)
|
|
Pierre-Yves Chibon |
cbbc1c |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
cbbc1c |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
cbbc1c |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
# Edit the sources file again
|
|
Pierre-Yves Chibon |
cbbc1c |
with open(os.path.join(newpath, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
cbbc1c |
stream.write('foo\n bar\nbaz\n boose')
|
|
Pierre-Yves Chibon |
cbbc1c |
new_repo.index.add('sources')
|
|
Pierre-Yves Chibon |
cbbc1c |
new_repo.index.write()
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
# Commits the files added
|
|
Pierre-Yves Chibon |
cbbc1c |
tree = new_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
cbbc1c |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
cbbc1c |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
cbbc1c |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
cbbc1c |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
cbbc1c |
new_repo.create_commit(
|
|
Pierre-Yves Chibon |
cbbc1c |
'refs/heads/feature',
|
|
Pierre-Yves Chibon |
cbbc1c |
author,
|
|
Pierre-Yves Chibon |
cbbc1c |
committer,
|
|
Pierre-Yves Chibon |
cbbc1c |
'A commit on branch feature',
|
|
Pierre-Yves Chibon |
cbbc1c |
tree,
|
|
Pierre-Yves Chibon |
cbbc1c |
[]
|
|
Pierre-Yves Chibon |
cbbc1c |
)
|
|
Pierre-Yves Chibon |
cbbc1c |
refname = 'refs/heads/feature:refs/heads/feature'
|
|
Pierre-Yves Chibon |
cbbc1c |
ori_remote = new_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
# Create a PR for these changes
|
|
Pierre-Yves Chibon |
cbbc1c |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
f9c5f9 |
req = pagure.lib.new_pull_request(
|
|
Pierre-Yves Chibon |
cbbc1c |
session=self.session,
|
|
Pierre-Yves Chibon |
cbbc1c |
repo_from=item,
|
|
Pierre-Yves Chibon |
cbbc1c |
branch_from='feature',
|
|
Pierre-Yves Chibon |
cbbc1c |
repo_to=project,
|
|
Pierre-Yves Chibon |
cbbc1c |
branch_to='master',
|
|
Pierre-Yves Chibon |
cbbc1c |
title='PR from the feature branch',
|
|
Pierre-Yves Chibon |
cbbc1c |
user='pingou',
|
|
Pierre-Yves Chibon |
cbbc1c |
requestfolder=None,
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
)
|
|
Pierre-Yves Chibon |
cbbc1c |
self.session.commit()
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.id, 1)
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.title, 'PR from the feature branch')
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
cbbc1c |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
cbbc1c |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
cbbc1c |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
fec7de |
self.assertTrue(
|
|
Pierre-Yves Chibon |
fec7de |
output.data.count('
|
|
Pierre-Yves Chibon |
cbbc1c |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
981ad4 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
981ad4 |
def test_request_pull_empty_fork(self, send_email):
|
|
Pierre-Yves Chibon |
981ad4 |
""" Test the request_pull endpoint from an empty fork. """
|
|
Pierre-Yves Chibon |
981ad4 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
981ad4 |
item = pagure.lib.model.Project(
|
|
Pierre-Yves Chibon |
981ad4 |
user_id=2, # foo
|
|
Pierre-Yves Chibon |
981ad4 |
name='test',
|
|
Pierre-Yves Chibon |
981ad4 |
description='test project #1',
|
|
Pierre-Yves Chibon |
981ad4 |
hook_token='aaabbb',
|
|
Pierre-Yves Chibon |
981ad4 |
parent_id=1,
|
|
Pierre-Yves Chibon |
981ad4 |
)
|
|
Pierre-Yves Chibon |
981ad4 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
981ad4 |
self.session.commit()
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
981ad4 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
981ad4 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
5bf6f1 |
os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True)
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
981ad4 |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
981ad4 |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
981ad4 |
os.makedirs(gitrepo)
|
|
Pierre-Yves Chibon |
981ad4 |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
981ad4 |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(
|
|
Pierre-Yves Chibon |
5bf6f1 |
tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
981ad4 |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
# Create a PR for these "changes" (there are none, both repos are
|
|
Pierre-Yves Chibon |
981ad4 |
# empty)
|
|
Pierre-Yves Chibon |
981ad4 |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
f9c5f9 |
req = pagure.lib.new_pull_request(
|
|
Pierre-Yves Chibon |
981ad4 |
session=self.session,
|
|
Pierre-Yves Chibon |
981ad4 |
repo_from=item,
|
|
Pierre-Yves Chibon |
981ad4 |
branch_from='feature',
|
|
Pierre-Yves Chibon |
981ad4 |
repo_to=project,
|
|
Pierre-Yves Chibon |
981ad4 |
branch_to='master',
|
|
Pierre-Yves Chibon |
981ad4 |
title='PR from the feature branch',
|
|
Pierre-Yves Chibon |
981ad4 |
user='pingou',
|
|
Pierre-Yves Chibon |
981ad4 |
requestfolder=None,
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
)
|
|
Pierre-Yves Chibon |
981ad4 |
self.session.commit()
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.id, 1)
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.title, 'PR from the feature branch')
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
981ad4 |
output = self.app.get('/test/pull-request/1', follow_redirects=True)
|
|
Pierre-Yves Chibon |
981ad4 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
981ad4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
981ad4 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
981ad4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Fork is empty, there are no '
|
|
Pierre-Yves Chibon |
19b2ae |
'commits to request pulling', output.data)
|
|
Pierre-Yves Chibon |
981ad4 |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
e8b89f |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
e8b89f |
def test_request_pulls(self, send_email):
|
|
Pierre-Yves Chibon |
a2d4e0 |
""" Test the request_pulls endpoint. """
|
|
Pierre-Yves Chibon |
e8b89f |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
e8b89f |
|
|
Pierre-Yves Chibon |
a2d4e0 |
# No such project
|
|
Pierre-Yves Chibon |
a2d4e0 |
output = self.app.get('/test/pull-requests')
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
a2d4e0 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
b243a0 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
b243a0 |
os.path.join(tests.HERE, 'repos'), bare=True)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
a2d4e0 |
output = self.app.get('/test/pull-requests')
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fec7de |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
'Pull Requests 0',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Ryan Lerch |
8cc0a8 |
# Open is primary
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests">Open', output.data)
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests?status=0">Closed', output.data)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.set_up_git_repo(new_project=None, branch_from='feature')
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
a2d4e0 |
output = self.app.get('/test/pull-requests')
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fec7de |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
'Pull Requests 1',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Ryan Lerch |
8cc0a8 |
# Open is primary
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests">Open', output.data)
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests?status=0">Closed', output.data)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
6e3c4b |
output = self.app.get('/test/pull-requests?status=Closed')
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fec7de |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
'Closed Pull Requests 0',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Ryan Lerch |
8cc0a8 |
# Close is primary
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests">Open', output.data)
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests?status=0">Closed', output.data)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
6e3c4b |
output = self.app.get('/test/pull-requests?status=0')
|
|
Pierre-Yves Chibon |
6e3c4b |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
fec7de |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
'Closed/Merged Pull Requests 0',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Ryan Lerch |
8cc0a8 |
# Close is primary
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests">Open', output.data)
|
|
Ryan Lerch |
8cc0a8 |
self.assertIn(
|
|
Ryan Lerch |
8cc0a8 |
'
|
|
Ryan Lerch |
8cc0a8 |
'href="/test/pull-requests?status=0">Closed', output.data)
|
|
Pierre-Yves Chibon |
6e3c4b |
|
|
Pierre-Yves Chibon |
a2d4e0 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
a2d4e0 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
a2d4e0 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
a2d4e0 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
a2d4e0 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.session.commit()
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
a2d4e0 |
output = self.app.get('/test/pull-requests')
|
|
Pierre-Yves Chibon |
a2d4e0 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
a2d4e0 |
|
|
Pierre-Yves Chibon |
d61bcb |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
d61bcb |
def test_request_pull_patch(self, send_email):
|
|
Pierre-Yves Chibon |
d61bcb |
""" Test the request_pull_patch endpoint. """
|
|
Pierre-Yves Chibon |
d61bcb |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
output = self.app.get('/test/pull-request/1.patch')
|
|
Pierre-Yves Chibon |
d61bcb |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
d61bcb |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
d61bcb |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
d61bcb |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
d61bcb |
new_project=None, branch_from='feature', mtype='merge')
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
output = self.app.get('/test/pull-request/100.patch')
|
|
Pierre-Yves Chibon |
d61bcb |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
output = self.app.get('/test/pull-request/1.patch')
|
|
Pierre-Yves Chibon |
d61bcb |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
npatch = []
|
|
Pierre-Yves Chibon |
d61bcb |
for row in output.data.split('\n'):
|
|
Pierre-Yves Chibon |
d61bcb |
if row.startswith('Date:'):
|
|
Pierre-Yves Chibon |
d61bcb |
continue
|
|
Pierre-Yves Chibon |
d61bcb |
if row.startswith('From '):
|
|
Pierre-Yves Chibon |
d61bcb |
row = row.split(' ', 2)[2]
|
|
Pierre-Yves Chibon |
d61bcb |
npatch.append(row)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
exp = """Mon Sep 17 00:00:00 2001
|
|
Pierre-Yves Chibon |
d61bcb |
From: Alice Author <alice@authors.tld></alice@authors.tld>
|
|
Pierre-Yves Chibon |
d61bcb |
Subject: A commit on branch feature
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
---
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
diff --git a/.gitignore b/.gitignore
|
|
Pierre-Yves Chibon |
d61bcb |
new file mode 100644
|
|
Pierre-Yves Chibon |
d61bcb |
index 0000000..e4e5f6c
|
|
Pierre-Yves Chibon |
d61bcb |
--- /dev/null
|
|
Pierre-Yves Chibon |
d61bcb |
+++ b/.gitignore
|
|
Pierre-Yves Chibon |
d61bcb |
@@ -0,0 +1 @@
|
|
Pierre-Yves Chibon |
d61bcb |
+*~
|
|
Pierre-Yves Chibon |
d61bcb |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
d61bcb |
diff --git a/sources b/sources
|
|
Pierre-Yves Chibon |
d61bcb |
index 9f44358..2a552bb 100644
|
|
Pierre-Yves Chibon |
d61bcb |
--- a/sources
|
|
Pierre-Yves Chibon |
d61bcb |
+++ b/sources
|
|
Pierre-Yves Chibon |
d61bcb |
@@ -1,2 +1,4 @@
|
|
Pierre-Yves Chibon |
d61bcb |
foo
|
|
Pierre-Yves Chibon |
d61bcb |
- bar
|
|
Pierre-Yves Chibon |
d61bcb |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
d61bcb |
+ bar
|
|
Pierre-Yves Chibon |
d61bcb |
+baz
|
|
Pierre-Yves Chibon |
d61bcb |
+ boose
|
|
Pierre-Yves Chibon |
d61bcb |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
"""
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
patch = '\n'.join(npatch)
|
|
Pierre-Yves Chibon |
d61bcb |
#print patch
|
|
Pierre-Yves Chibon |
d61bcb |
self.assertEqual(patch, exp)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
d61bcb |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
d61bcb |
settings = repo.settings
|
|
Pierre-Yves Chibon |
d61bcb |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
d61bcb |
repo.settings = settings
|
|
Pierre-Yves Chibon |
d61bcb |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
d61bcb |
self.session.commit()
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
d61bcb |
output = self.app.get('/test/pull-request/1.patch')
|
|
Pierre-Yves Chibon |
d61bcb |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d61bcb |
|
|
Pierre-Yves Chibon |
b54ac4 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
f75e13 |
def test_request_pull_patch_close(self, send_email):
|
|
Pierre-Yves Chibon |
f75e13 |
""" Test the request_pull_patch endpoint with a closed PR. """
|
|
Pierre-Yves Chibon |
f75e13 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
self.test_merge_request_pull_FF()
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
output = self.app.get('/test/pull-request/1.patch')
|
|
Pierre-Yves Chibon |
f75e13 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
npatch = []
|
|
Pierre-Yves Chibon |
f75e13 |
for row in output.data.split('\n'):
|
|
Pierre-Yves Chibon |
f75e13 |
if row.startswith('Date:'):
|
|
Pierre-Yves Chibon |
f75e13 |
continue
|
|
Pierre-Yves Chibon |
f75e13 |
if row.startswith('From '):
|
|
Pierre-Yves Chibon |
f75e13 |
row = row.split(' ', 2)[2]
|
|
Pierre-Yves Chibon |
f75e13 |
npatch.append(row)
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
exp = """Mon Sep 17 00:00:00 2001
|
|
Pierre-Yves Chibon |
f75e13 |
From: Alice Author <alice@authors.tld></alice@authors.tld>
|
|
Pierre-Yves Chibon |
f75e13 |
Subject: A commit on branch feature
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
---
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
diff --git a/sources b/sources
|
|
Pierre-Yves Chibon |
f75e13 |
index 9f44358..2a552bb 100644
|
|
Pierre-Yves Chibon |
f75e13 |
--- a/sources
|
|
Pierre-Yves Chibon |
f75e13 |
+++ b/sources
|
|
Pierre-Yves Chibon |
f75e13 |
@@ -1,2 +1,4 @@
|
|
Pierre-Yves Chibon |
f75e13 |
foo
|
|
Pierre-Yves Chibon |
f75e13 |
- bar
|
|
Pierre-Yves Chibon |
f75e13 |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
f75e13 |
+ bar
|
|
Pierre-Yves Chibon |
f75e13 |
+baz
|
|
Pierre-Yves Chibon |
f75e13 |
+ boose
|
|
Pierre-Yves Chibon |
f75e13 |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
"""
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
patch = '\n'.join(npatch)
|
|
Pierre-Yves Chibon |
f75e13 |
#print patch
|
|
Pierre-Yves Chibon |
f75e13 |
self.assertEqual(patch, exp)
|
|
Pierre-Yves Chibon |
f75e13 |
|
|
Pierre-Yves Chibon |
f75e13 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
300a00 |
def test_request_pull_patch_empty_repo(self, send_email):
|
|
Pierre-Yves Chibon |
300a00 |
""" Test the request_pull_patch endpoint against an empty repo. """
|
|
Pierre-Yves Chibon |
300a00 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
300a00 |
item = pagure.lib.model.Project(
|
|
Pierre-Yves Chibon |
300a00 |
user_id=2, # foo
|
|
Pierre-Yves Chibon |
300a00 |
name='test',
|
|
Pierre-Yves Chibon |
300a00 |
description='test project #1',
|
|
Pierre-Yves Chibon |
300a00 |
hook_token='aaabbb',
|
|
Pierre-Yves Chibon |
300a00 |
parent_id=1,
|
|
Pierre-Yves Chibon |
300a00 |
)
|
|
Pierre-Yves Chibon |
300a00 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
300a00 |
self.session.commit()
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
300a00 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
300a00 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
5bf6f1 |
os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
300a00 |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
300a00 |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
300a00 |
os.makedirs(gitrepo)
|
|
Pierre-Yves Chibon |
300a00 |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
300a00 |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(
|
|
Pierre-Yves Chibon |
5bf6f1 |
tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
300a00 |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
# Edit the sources file again
|
|
Pierre-Yves Chibon |
300a00 |
with open(os.path.join(newpath, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
300a00 |
stream.write('foo\n bar\nbaz\n boose')
|
|
Pierre-Yves Chibon |
300a00 |
new_repo.index.add('sources')
|
|
Pierre-Yves Chibon |
300a00 |
new_repo.index.write()
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
# Commits the files added
|
|
Pierre-Yves Chibon |
300a00 |
tree = new_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
300a00 |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
300a00 |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
300a00 |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
300a00 |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
300a00 |
new_repo.create_commit(
|
|
Pierre-Yves Chibon |
300a00 |
'refs/heads/feature',
|
|
Pierre-Yves Chibon |
300a00 |
author,
|
|
Pierre-Yves Chibon |
300a00 |
committer,
|
|
Pierre-Yves Chibon |
300a00 |
'A commit on branch feature',
|
|
Pierre-Yves Chibon |
300a00 |
tree,
|
|
Pierre-Yves Chibon |
300a00 |
[]
|
|
Pierre-Yves Chibon |
300a00 |
)
|
|
Pierre-Yves Chibon |
300a00 |
refname = 'refs/heads/feature:refs/heads/feature'
|
|
Pierre-Yves Chibon |
300a00 |
ori_remote = new_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
# Create a PR for these "changes" (there are none, both repos are
|
|
Pierre-Yves Chibon |
300a00 |
# empty)
|
|
Pierre-Yves Chibon |
300a00 |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
f9c5f9 |
req = pagure.lib.new_pull_request(
|
|
Pierre-Yves Chibon |
300a00 |
session=self.session,
|
|
Pierre-Yves Chibon |
300a00 |
repo_from=item,
|
|
Pierre-Yves Chibon |
300a00 |
branch_from='feature',
|
|
Pierre-Yves Chibon |
300a00 |
repo_to=project,
|
|
Pierre-Yves Chibon |
300a00 |
branch_to='master',
|
|
Pierre-Yves Chibon |
300a00 |
title='PR from the feature branch',
|
|
Pierre-Yves Chibon |
300a00 |
user='pingou',
|
|
Pierre-Yves Chibon |
300a00 |
requestfolder=None,
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
)
|
|
Pierre-Yves Chibon |
300a00 |
self.session.commit()
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.id, 1)
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.title, 'PR from the feature branch')
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
5bf6f1 |
output = self.app.get(
|
|
Pierre-Yves Chibon |
5bf6f1 |
'/test/pull-request/1.patch', follow_redirects=True)
|
|
Pierre-Yves Chibon |
300a00 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
npatch = []
|
|
Pierre-Yves Chibon |
300a00 |
for row in output.data.split('\n'):
|
|
Pierre-Yves Chibon |
300a00 |
if row.startswith('Date:'):
|
|
Pierre-Yves Chibon |
300a00 |
continue
|
|
Pierre-Yves Chibon |
300a00 |
if row.startswith('From '):
|
|
Pierre-Yves Chibon |
300a00 |
row = row.split(' ', 2)[2]
|
|
Pierre-Yves Chibon |
300a00 |
npatch.append(row)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
exp = """Mon Sep 17 00:00:00 2001
|
|
Pierre-Yves Chibon |
300a00 |
From: Alice Author <alice@authors.tld></alice@authors.tld>
|
|
Pierre-Yves Chibon |
300a00 |
Subject: A commit on branch feature
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
---
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
diff --git a/sources b/sources
|
|
Pierre-Yves Chibon |
300a00 |
new file mode 100644
|
|
Pierre-Yves Chibon |
300a00 |
index 0000000..2a552bb
|
|
Pierre-Yves Chibon |
300a00 |
--- /dev/null
|
|
Pierre-Yves Chibon |
300a00 |
+++ b/sources
|
|
Pierre-Yves Chibon |
300a00 |
@@ -0,0 +1,4 @@
|
|
Pierre-Yves Chibon |
300a00 |
+foo
|
|
Pierre-Yves Chibon |
300a00 |
+ bar
|
|
Pierre-Yves Chibon |
300a00 |
+baz
|
|
Pierre-Yves Chibon |
300a00 |
+ boose
|
|
Pierre-Yves Chibon |
300a00 |
\ No newline at end of file
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
"""
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
300a00 |
patch = '\n'.join(npatch)
|
|
Pierre-Yves Chibon |
300a00 |
#print patch
|
|
Pierre-Yves Chibon |
300a00 |
self.assertEqual(patch, exp)
|
|
Pierre-Yves Chibon |
300a00 |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
300a00 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
b54ac4 |
def test_request_pull_patch_empty_fork(self, send_email):
|
|
Pierre-Yves Chibon |
b54ac4 |
""" Test the request_pull_patch endpoint from an empty fork. """
|
|
Pierre-Yves Chibon |
b54ac4 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
b54ac4 |
item = pagure.lib.model.Project(
|
|
Pierre-Yves Chibon |
b54ac4 |
user_id=2, # foo
|
|
Pierre-Yves Chibon |
b54ac4 |
name='test',
|
|
Pierre-Yves Chibon |
b54ac4 |
description='test project #1',
|
|
Pierre-Yves Chibon |
b54ac4 |
hook_token='aaabbb',
|
|
Pierre-Yves Chibon |
b54ac4 |
parent_id=1,
|
|
Pierre-Yves Chibon |
b54ac4 |
)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.session.commit()
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
b54ac4 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
b54ac4 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
5bf6f1 |
os.path.join(tests.HERE, 'repos', 'forks', 'foo'), bare=True)
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
b54ac4 |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
b54ac4 |
self.assertFalse(os.path.exists(gitrepo))
|
|
Pierre-Yves Chibon |
b54ac4 |
os.makedirs(gitrepo)
|
|
Pierre-Yves Chibon |
b54ac4 |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
b54ac4 |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(
|
|
Pierre-Yves Chibon |
5bf6f1 |
tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
b54ac4 |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
# Create a PR for these "changes" (there are none, both repos are
|
|
Pierre-Yves Chibon |
b54ac4 |
# empty)
|
|
Pierre-Yves Chibon |
b54ac4 |
project = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
f9c5f9 |
req = pagure.lib.new_pull_request(
|
|
Pierre-Yves Chibon |
b54ac4 |
session=self.session,
|
|
Pierre-Yves Chibon |
b54ac4 |
repo_from=item,
|
|
Pierre-Yves Chibon |
b54ac4 |
branch_from='feature',
|
|
Pierre-Yves Chibon |
b54ac4 |
repo_to=project,
|
|
Pierre-Yves Chibon |
b54ac4 |
branch_to='master',
|
|
Pierre-Yves Chibon |
b54ac4 |
title='PR from the feature branch',
|
|
Pierre-Yves Chibon |
b54ac4 |
user='pingou',
|
|
Pierre-Yves Chibon |
b54ac4 |
requestfolder=None,
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.session.commit()
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.id, 1)
|
|
Pierre-Yves Chibon |
f9c5f9 |
self.assertEqual(req.title, 'PR from the feature branch')
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
b54ac4 |
output = self.app.get('/test/pull-request/1.patch', follow_redirects=True)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
b54ac4 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
b54ac4 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Fork is empty, there are no '
|
|
Pierre-Yves Chibon |
19b2ae |
'commits to request pulling', output.data)
|
|
Pierre-Yves Chibon |
b54ac4 |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
ccefd8 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
ccefd8 |
def test_cancel_request_pull(self, send_email):
|
|
Pierre-Yves Chibon |
ccefd8 |
""" Test the cancel_request_pull endpoint. """
|
|
Pierre-Yves Chibon |
ccefd8 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
ccefd8 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
ccefd8 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
ccefd8 |
new_project=None, branch_from='feature', mtype='merge')
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
ccefd8 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post('/test/pull-request/cancel/1')
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 302)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/test/pull-request/cancel/1', follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
ccefd8 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Invalid input submitted',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
ccefd8 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
data = {
|
|
Pierre-Yves Chibon |
ccefd8 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
ccefd8 |
}
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
# Invalid project
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/foo/pull-request/cancel/1', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
# Invalid PR id
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/test/pull-request/cancel/100', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
# Invalid user for this project
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/test/pull-request/cancel/1', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
ccefd8 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
ccefd8 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
ccefd8 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
ccefd8 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
ccefd8 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
ccefd8 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
ccefd8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/test/pull-request/cancel/1', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
ccefd8 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
ccefd8 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
ccefd8 |
settings['pull_requests'] = True
|
|
Pierre-Yves Chibon |
ccefd8 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
ccefd8 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.session.commit()
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
ccefd8 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
ccefd8 |
'/test/pull-request/cancel/1', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
ccefd8 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
ccefd8 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Request pull canceled!',
|
|
Pierre-Yves Chibon |
ccefd8 |
output.data)
|
|
Pierre-Yves Chibon |
ccefd8 |
|
|
Pierre-Yves Chibon |
005063 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
005063 |
def test_set_assignee_requests(self, send_email):
|
|
Pierre-Yves Chibon |
005063 |
""" Test the set_assignee_requests endpoint. """
|
|
Pierre-Yves Chibon |
005063 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
005063 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
005063 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
005063 |
self.set_up_git_repo(new_project=None, branch_from='feature')
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
user = tests.FakeUser()
|
|
Ryan Lerch |
deaa7c |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
005063 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
2af4a0 |
# No such project
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post('/foo/pull-request/1/assign')
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post('/test/pull-request/100/assign')
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# Invalid input
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Ryan Lerch |
deaa7c |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Request assigned',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
005063 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
data = {
|
|
Pierre-Yves Chibon |
005063 |
'user': 'pingou',
|
|
Pierre-Yves Chibon |
005063 |
}
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# No CSRF
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
005063 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Ryan Lerch |
deaa7c |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Request assigned',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# Invalid assignee
|
|
Pierre-Yves Chibon |
005063 |
data = {
|
|
Pierre-Yves Chibon |
005063 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
005063 |
'user': 'bar',
|
|
Pierre-Yves Chibon |
005063 |
}
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
005063 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Ryan Lerch |
deaa7c |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n No user "bar" found',
|
|
Pierre-Yves Chibon |
005063 |
output.data)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# Assign the PR
|
|
Pierre-Yves Chibon |
005063 |
data = {
|
|
Pierre-Yves Chibon |
005063 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
005063 |
'user': 'pingou',
|
|
Pierre-Yves Chibon |
005063 |
}
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
2af4a0 |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
2af4a0 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
2af4a0 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
2af4a0 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
2af4a0 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
2af4a0 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
2af4a0 |
|
|
Pierre-Yves Chibon |
2af4a0 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
2af4a0 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
005063 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Ryan Lerch |
deaa7c |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
005063 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Request assigned',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# Pull-Request closed
|
|
Pierre-Yves Chibon |
005063 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
005063 |
req = repo.requests[0]
|
|
Pierre-Yves Chibon |
ce0f3f |
req.status = 'Closed'
|
|
Pierre-Yves Chibon |
ce0f3f |
req.closed_by_in = 1
|
|
Pierre-Yves Chibon |
005063 |
self.session.add(req)
|
|
Pierre-Yves Chibon |
005063 |
self.session.commit()
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
005063 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
005063 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
005063 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
005063 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
005063 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
005063 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
005063 |
self.session.commit()
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
005063 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
005063 |
'/test/pull-request/1/assign', data=data,
|
|
Pierre-Yves Chibon |
005063 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
005063 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
005063 |
|
|
Pierre-Yves Chibon |
652a23 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
652a23 |
def test_fork_project(self, send_email):
|
|
Pierre-Yves Chibon |
652a23 |
""" Test the fork_project endpoint. """
|
|
Pierre-Yves Chibon |
652a23 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
2099a6 |
for folder in ['docs', 'tickets', 'requests', 'repos']:
|
|
Pierre-Yves Chibon |
652a23 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
652a23 |
os.path.join(tests.HERE, folder), bare=True)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
652a23 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
652a23 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
652a23 |
output = self.app.post('/do_fork/test')
|
|
Pierre-Yves Chibon |
652a23 |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
output = self.app.get('/new/')
|
|
Pierre-Yves Chibon |
652a23 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
99b438 |
self.assertIn('Create new Project', output.data)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
652a23 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
data = {
|
|
Pierre-Yves Chibon |
652a23 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
652a23 |
}
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
652a23 |
'/do_fork/foo', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
652a23 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
652a23 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
652a23 |
output = self.app.post('/do_fork/test')
|
|
Pierre-Yves Chibon |
652a23 |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
data = {
|
|
Pierre-Yves Chibon |
652a23 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
652a23 |
}
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
652a23 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
652a23 |
'/do_fork/test', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
652a23 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
652a23 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Repo "test" '
|
|
Pierre-Yves Chibon |
19b2ae |
'cloned to "foo/test"', output.data)
|
|
Pierre-Yves Chibon |
652a23 |
|
|
Pierre-Yves Chibon |
cec97d |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
cec97d |
def test_new_request_pull(self, send_email):
|
|
Pierre-Yves Chibon |
cec97d |
""" Test the new_request_pull endpoint. """
|
|
Pierre-Yves Chibon |
cec97d |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
self.test_fork_project()
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
cec97d |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
cec97d |
fork = pagure.lib.get_project(self.session, 'test', user='foo')
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
self.set_up_git_repo(
|
|
Pierre-Yves Chibon |
cec97d |
new_project=fork, branch_from='feature', mtype='FF')
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
cec97d |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
cec97d |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/foo/diff/master..feature')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/test/diff/master..foo')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/test/diff/foo..master')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/test/diff/feature..master')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
6e6a42 |
'<title>Diff from master to feature - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
cec97d |
output.data)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
' No commits found ', output.data)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
6e6a42 |
'<title>Diff from feature to master - test - Pagure</title>',
|
|
Pierre-Yves Chibon |
cec97d |
output.data)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
cec97d |
'
|
|
Pierre-Yves Chibon |
cec97d |
'value="Create">', output.data)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
cec97d |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title> Create new Pull Request for master - test - '</title>
|
|
Pierre-Yves Chibon |
99b438 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
fec7de |
'<input class="btn btn-primary" type="submit" value="Create">',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
cec97d |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Clement Verna |
43d191 |
# Case 1 - Add an initial comment
|
|
Pierre-Yves Chibon |
cec97d |
data = {
|
|
Pierre-Yves Chibon |
cec97d |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
cec97d |
'title': 'foo bar PR',
|
|
Clement Verna |
f6e82b |
'initial_comment': 'Test Initial Comment',
|
|
Pierre-Yves Chibon |
cec97d |
}
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Pierre-Yves Chibon |
cec97d |
output = self.app.post(
|
|
Pierre-Yves Chibon |
cec97d |
'/test/diff/master..feature', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
cec97d |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#2: foo bar PR - test\n - Pagure</title>',
|
|
Pierre-Yves Chibon |
f9c5f9 |
output.data)
|
|
Clement Verna |
f6e82b |
self.assertIn('Test Initial Comment ', output.data)
|
|
Pierre-Yves Chibon |
cec97d |
|
|
Clement Verna |
43d191 |
|
|
Clement Verna |
43d191 |
# Case 2 - Add an empty initial comment
|
|
Clement Verna |
43d191 |
data = {
|
|
Clement Verna |
43d191 |
'csrf_token': csrf_token,
|
|
Clement Verna |
43d191 |
'title': 'foo bar PR',
|
|
Clement Verna |
43d191 |
'initial_comment': '',
|
|
Clement Verna |
43d191 |
}
|
|
Clement Verna |
43d191 |
|
|
Clement Verna |
43d191 |
output = self.app.post(
|
|
Clement Verna |
43d191 |
'/test/diff/master..feature', data=data, follow_redirects=True)
|
|
Clement Verna |
43d191 |
self.assertEqual(output.status_code, 200)
|
|
Clement Verna |
43d191 |
self.assertIn(
|
|
Clement Verna |
43d191 |
'<title>PR#3: foo bar PR - test\n - Pagure</title>',
|
|
Clement Verna |
43d191 |
output.data)
|
|
Clement Verna |
43d191 |
self.assertNotIn('
|
|
Clement Verna |
43d191 |
|
|
Pierre-Yves Chibon |
5fb13f |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
5fb13f |
def test_new_request_pull_empty_repo(self, send_email):
|
|
Pierre-Yves Chibon |
5fb13f |
""" Test the new_request_pull endpoint against an empty repo. """
|
|
Pierre-Yves Chibon |
5fb13f |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
self.test_fork_project()
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
5fb13f |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
5fb13f |
fork = pagure.lib.get_project(self.session, 'test', user='foo')
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
5fb13f |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
5fb13f |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
5fb13f |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
5fb13f |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
5fb13f |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
5fb13f |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
4a3837 |
output = self.app.get(
|
|
Pierre-Yves Chibon |
4a3837 |
'/fork/foo/test/diff/master..feature',
|
|
Pierre-Yves Chibon |
4a3837 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertIn(
|
|
Pierre-Yves Chibon |
4a3837 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Fork is empty, there are '
|
|
Pierre-Yves Chibon |
19b2ae |
'no commits to request pulling', output.data)
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
bab89f |
output = self.app.get('/test/new_issue')
|
|
Pierre-Yves Chibon |
5fb13f |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
5fb13f |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
data = {
|
|
Pierre-Yves Chibon |
5fb13f |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
5fb13f |
'title': 'foo bar PR',
|
|
Pierre-Yves Chibon |
5fb13f |
}
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
5fb13f |
output = self.app.post(
|
|
Pierre-Yves Chibon |
5fb13f |
'/test/diff/master..feature', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertIn(
|
|
Pierre-Yves Chibon |
5fb13f |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
5fb13f |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Fork is empty, there are '
|
|
Pierre-Yves Chibon |
19b2ae |
'no commits to request pulling', output.data)
|
|
Pierre-Yves Chibon |
5fb13f |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
c18cb0 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
c18cb0 |
def test_new_request_pull_empty_fork(self, send_email):
|
|
Pierre-Yves Chibon |
c18cb0 |
""" Test the new_request_pull endpoint against an empty repo. """
|
|
Pierre-Yves Chibon |
c18cb0 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
self.test_fork_project()
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
tests.create_projects_git(
|
|
Pierre-Yves Chibon |
c18cb0 |
os.path.join(tests.HERE, 'requests'), bare=True)
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
c18cb0 |
fork = pagure.lib.get_project(self.session, 'test', user='foo')
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
# Create a git repo to play with
|
|
Pierre-Yves Chibon |
c18cb0 |
gitrepo = os.path.join(tests.HERE, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
c18cb0 |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
# Create a fork of this repo
|
|
Pierre-Yves Chibon |
c18cb0 |
newpath = tempfile.mkdtemp(prefix='pagure-fork-test')
|
|
Pierre-Yves Chibon |
5bf6f1 |
gitrepo = os.path.join(
|
|
Pierre-Yves Chibon |
5bf6f1 |
tests.HERE, 'repos', 'forks', 'foo', 'test.git')
|
|
Pierre-Yves Chibon |
c18cb0 |
new_repo = pygit2.clone_repository(gitrepo, newpath)
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
c18cb0 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
c18cb0 |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
c18cb0 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
c18cb0 |
output = self.app.get(
|
|
Pierre-Yves Chibon |
c18cb0 |
'/fork/foo/test/diff/master..master', follow_redirects=True)
|
|
Pierre-Yves Chibon |
c18cb0 |
self.assertIn(
|
|
Pierre-Yves Chibon |
c18cb0 |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
c18cb0 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Fork is empty, there are '
|
|
Pierre-Yves Chibon |
19b2ae |
'no commits to request pulling', output.data)
|
|
Pierre-Yves Chibon |
c18cb0 |
|
|
Pierre-Yves Chibon |
54d454 |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
54d454 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
eeb8a9 |
def test_pull_request_add_comment(self, send_email):
|
|
Pierre-Yves Chibon |
eeb8a9 |
""" Test the pull_request_add_comment endpoint. """
|
|
Pierre-Yves Chibon |
eeb8a9 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.test_request_pull()
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
eeb8a9 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
eeb8a9 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
eeb8a9 |
output = self.app.post('/foo/pull-request/1/comment')
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
output = self.app.post('/test/pull-request/100/comment')
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
output = self.app.post('/test/pull-request/1/comment')
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertTrue(
|
|
Pierre-Yves Chibon |
4fcf92 |
output.data.startswith('\n<section class="add_comment">'))</section>
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
eeb8a9 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
data = {
|
|
Pierre-Yves Chibon |
eeb8a9 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
eeb8a9 |
'comment': 'This look alright but we can do better',
|
|
Pierre-Yves Chibon |
eeb8a9 |
}
|
|
Pierre-Yves Chibon |
eeb8a9 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
eeb8a9 |
'/test/pull-request/1/comment', data=data,
|
|
Pierre-Yves Chibon |
eeb8a9 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertIn(
|
|
Pierre-Yves Chibon |
99b438 |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
6e6a42 |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Comment added',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
eeb8a9 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
eeb8a9 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
eeb8a9 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
eeb8a9 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.session.commit()
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
eeb8a9 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
eeb8a9 |
'/test/pull-request/1/comment', data=data,
|
|
Pierre-Yves Chibon |
eeb8a9 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
eeb8a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
eeb8a9 |
|
|
Pierre-Yves Chibon |
6d9a52 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
6d9a52 |
def test_pull_request_drop_comment(self, send_email):
|
|
Pierre-Yves Chibon |
6d9a52 |
""" Test the pull_request_drop_comment endpoint. """
|
|
Pierre-Yves Chibon |
6d9a52 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
self.test_pull_request_add_comment()
|
|
Pierre-Yves Chibon |
6d9a52 |
# Project w/ pull-request
|
|
Pierre-Yves Chibon |
6d9a52 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
6d9a52 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
6d9a52 |
settings['pull_requests'] = True
|
|
Pierre-Yves Chibon |
6d9a52 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
6d9a52 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.session.commit()
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
6d9a52 |
user.username = 'foo'
|
|
Pierre-Yves Chibon |
6d9a52 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post('/foo/pull-request/1/comment/drop')
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post('/test/pull-request/100/comment/drop')
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
6d9a52 |
'/test/pull-request/1/comment/drop', follow_redirects=True)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
99b438 |
#self.assertIn('href="#comment-1">¶', output.data)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertIn(
|
|
Pierre-Yves Chibon |
6d9a52 |
'This look alright but we can do better ',
|
|
Pierre-Yves Chibon |
6d9a52 |
output.data)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
6d9a52 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
# Invalid comment id
|
|
Pierre-Yves Chibon |
6d9a52 |
data = {
|
|
Pierre-Yves Chibon |
6d9a52 |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
6d9a52 |
'drop_comment': '10',
|
|
Pierre-Yves Chibon |
6d9a52 |
}
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
6d9a52 |
'/test/pull-request/1/comment/drop', data=data,
|
|
Pierre-Yves Chibon |
6d9a52 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
data['drop_comment'] = '1'
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
6d9a52 |
'/test/pull-request/1/comment/drop', data=data,
|
|
Pierre-Yves Chibon |
6d9a52 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
6d9a52 |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
6d9a52 |
# Drop comment
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
6d9a52 |
'/test/pull-request/1/comment/drop', data=data,
|
|
Pierre-Yves Chibon |
6d9a52 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Comment removed',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
# Project w/o pull-request
|
|
Pierre-Yves Chibon |
6d9a52 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
6d9a52 |
settings = repo.settings
|
|
Pierre-Yves Chibon |
6d9a52 |
settings['pull_requests'] = False
|
|
Pierre-Yves Chibon |
6d9a52 |
repo.settings = settings
|
|
Pierre-Yves Chibon |
6d9a52 |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.session.commit()
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
Pierre-Yves Chibon |
6d9a52 |
output = self.app.post(
|
|
Pierre-Yves Chibon |
6d9a52 |
'/test/pull-request/1/comment/drop', data=data,
|
|
Pierre-Yves Chibon |
6d9a52 |
follow_redirects=True)
|
|
Pierre-Yves Chibon |
6d9a52 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
6d9a52 |
|
|
farhaanbukhsh |
a04e02 |
@patch('pagure.lib.notify.send_email')
|
|
farhaanbukhsh |
a04e02 |
def test_pull_request_edit_comment(self, send_email):
|
|
farhaanbukhsh |
a04e02 |
""" Test the pull request edit comment endpoint """
|
|
farhaanbukhsh |
a04e02 |
send_email.return_value = True
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
self.test_request_pull()
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
user = tests.FakeUser()
|
|
farhaanbukhsh |
a04e02 |
user.username = 'pingou'
|
|
farhaanbukhsh |
a04e02 |
with tests.user_set(pagure.APP, user):
|
|
farhaanbukhsh |
a04e02 |
# Repo 'foo' does not exist so it is verifying that condition
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post('/foo/pull-request/1/comment/1/edit')
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 404)
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
# Here no comment is present in the PR so its verifying that condition
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post('/test/pull-request/100/comment/100/edit')
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 404)
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post('/test/pull-request/1/comment')
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 200)
|
|
farhaanbukhsh |
a04e02 |
# Creating comment to play with
|
|
farhaanbukhsh |
a04e02 |
self.assertTrue(
|
|
Pierre-Yves Chibon |
4fcf92 |
output.data.startswith('\n<section class="add_comment">'))</section>
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
csrf_token = output.data.split(
|
|
farhaanbukhsh |
a04e02 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
data = {
|
|
farhaanbukhsh |
a04e02 |
'csrf_token': csrf_token,
|
|
farhaanbukhsh |
a04e02 |
'comment': 'This look alright but we can do better',
|
|
farhaanbukhsh |
a04e02 |
}
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post(
|
|
farhaanbukhsh |
a04e02 |
'/test/pull-request/1/comment', data=data,
|
|
farhaanbukhsh |
a04e02 |
follow_redirects=True)
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 200)
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Comment added',
|
|
Pierre-Yves Chibon |
19b2ae |
output.data)
|
|
farhaanbukhsh |
a04e02 |
# Check if the comment is there
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
farhaanbukhsh |
a04e02 |
'This look alright but we can do better ', output.data)
|
|
farhaanbukhsh |
a04e02 |
output = self.app.get('/test/pull-request/1/comment/1/edit')
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 200)
|
|
farhaanbukhsh |
a04e02 |
|
|
Pierre-Yves Chibon |
e64141 |
self.assertIn('<section class="edit_comment">', output.data)</section>
|
|
farhaanbukhsh |
a04e02 |
# Checking if the comment is there in the update page
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
farhaanbukhsh |
a04e02 |
'This look alright but we can do better', output.data)
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
csrf_token = output.data.split(
|
|
farhaanbukhsh |
a04e02 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
data = {
|
|
farhaanbukhsh |
a04e02 |
'csrf_token': csrf_token,
|
|
farhaanbukhsh |
a04e02 |
'update_comment': 'This look alright but we can do better than this.',
|
|
farhaanbukhsh |
a04e02 |
}
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post(
|
|
farhaanbukhsh |
a04e02 |
'/test/pull-request/1/comment/1/edit', data=data,
|
|
farhaanbukhsh |
a04e02 |
follow_redirects=True)
|
|
farhaanbukhsh |
a04e02 |
# Checking if the comment is updated in the main page
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
farhaanbukhsh |
a04e02 |
'This look alright but we can do better than this. ', output.data)
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
Pierre-Yves Chibon |
137f65 |
'PR#1\n'
|
|
Pierre-Yves Chibon |
137f65 |
' PR from the feature branch\n ',
|
|
Pierre-Yves Chibon |
fec7de |
output.data)
|
|
farhaanbukhsh |
a04e02 |
# Checking if Edited by User is there or not
|
|
Pierre-Yves Chibon |
cf5986 |
self.assertTrue(
|
|
Pierre-Yves Chibon |
cf5986 |
'<small class="text-muted">Edited just now by pingou </small>'
|
|
Pierre-Yves Chibon |
cf5986 |
in output.data
|
|
Pierre-Yves Chibon |
cf5986 |
or
|
|
Pierre-Yves Chibon |
cf5986 |
'<small class="text-muted">Edited seconds ago by pingou </small>'
|
|
Pierre-Yves Chibon |
cf5986 |
in output.data)
|
|
farhaanbukhsh |
a04e02 |
self.assertIn(
|
|
Pierre-Yves Chibon |
19b2ae |
'\n Comment updated', output.data)
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
# Project w/o pull-request
|
|
farhaanbukhsh |
a04e02 |
repo = pagure.lib.get_project(self.session, 'test')
|
|
farhaanbukhsh |
a04e02 |
settings = repo.settings
|
|
farhaanbukhsh |
a04e02 |
settings['pull_requests'] = False
|
|
farhaanbukhsh |
a04e02 |
repo.settings = settings
|
|
farhaanbukhsh |
a04e02 |
self.session.add(repo)
|
|
farhaanbukhsh |
a04e02 |
self.session.commit()
|
|
farhaanbukhsh |
a04e02 |
|
|
farhaanbukhsh |
a04e02 |
output = self.app.post(
|
|
farhaanbukhsh |
a04e02 |
'/test/pull-request/1/comment/edit/1', data=data,
|
|
farhaanbukhsh |
a04e02 |
follow_redirects=True)
|
|
farhaanbukhsh |
a04e02 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
9347b5 |
|
|
Pierre-Yves Chibon |
edfd4c |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
edfd4c |
def test_merge_request_pull_FF_w_merge_commit(self, send_email):
|
|
Pierre-Yves Chibon |
edfd4c |
""" Test the merge_request_pull endpoint with a FF PR but with a
|
|
Pierre-Yves Chibon |
edfd4c |
merge commit.
|
|
Pierre-Yves Chibon |
edfd4c |
"""
|
|
Pierre-Yves Chibon |
edfd4c |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
self.test_request_pull()
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
edfd4c |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
csrf_token = output.data.split(
|
|
Pierre-Yves Chibon |
edfd4c |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# No CSRF
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.post(
|
|
Pierre-Yves Chibon |
edfd4c |
'/test/pull-request/1/merge', data={}, follow_redirects=True)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'<title>PR#1: PR from the feature branch - test\n - '</title>
|
|
Pierre-Yves Chibon |
edfd4c |
'Pagure', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'PR#1\n'
|
|
Pierre-Yves Chibon |
edfd4c |
' PR from the feature branch\n', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
15a1bc |
'title="View file as of 2a552b">sources', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# Wrong project
|
|
Pierre-Yves Chibon |
edfd4c |
data = {
|
|
Pierre-Yves Chibon |
edfd4c |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
edfd4c |
}
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.post(
|
|
Pierre-Yves Chibon |
edfd4c |
'/foobar/pull-request/100/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# Wrong project
|
|
Pierre-Yves Chibon |
edfd4c |
data = {
|
|
Pierre-Yves Chibon |
edfd4c |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
edfd4c |
}
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.post(
|
|
Pierre-Yves Chibon |
edfd4c |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
user.username = 'pingou'
|
|
Pierre-Yves Chibon |
edfd4c |
with tests.user_set(pagure.APP, user):
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# Wrong request id
|
|
Pierre-Yves Chibon |
edfd4c |
data = {
|
|
Pierre-Yves Chibon |
edfd4c |
'csrf_token': csrf_token,
|
|
Pierre-Yves Chibon |
edfd4c |
}
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.post(
|
|
Pierre-Yves Chibon |
edfd4c |
'/test/pull-request/100/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# Project requiring a merge commit
|
|
Pierre-Yves Chibon |
edfd4c |
repo = pagure.lib.get_project(self.session, 'test')
|
|
Pierre-Yves Chibon |
edfd4c |
settings = repo.settings
|
|
Pierre-Yves Chibon |
edfd4c |
settings['always_merge'] = True
|
|
Pierre-Yves Chibon |
edfd4c |
repo.settings = settings
|
|
Pierre-Yves Chibon |
edfd4c |
self.session.add(repo)
|
|
Pierre-Yves Chibon |
edfd4c |
self.session.commit()
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
edfd4c |
# Merge
|
|
Pierre-Yves Chibon |
edfd4c |
output = self.app.post(
|
|
Pierre-Yves Chibon |
edfd4c |
'/test/pull-request/1/merge', data=data, follow_redirects=True)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'<title>Overview - test - Pagure</title>', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'\n Changes merged!',
|
|
Pierre-Yves Chibon |
edfd4c |
output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'Merge #1 `PR from the feature branch`', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertIn(
|
|
Pierre-Yves Chibon |
edfd4c |
'A commit on branch feature', output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
# Ensure we have the merge commit
|
|
Pierre-Yves Chibon |
edfd4c |
commits = _get_commits(output.data)
|
|
Pierre-Yves Chibon |
edfd4c |
self.assertEqual(commits, [
|
|
Pierre-Yves Chibon |
edfd4c |
'Merge #1 `PR from the feature branch`',
|
|
Pierre-Yves Chibon |
edfd4c |
'Add sources file for testing',
|
|
Pierre-Yves Chibon |
edfd4c |
'A commit on branch feature',
|
|
Pierre-Yves Chibon |
edfd4c |
])
|
|
Pierre-Yves Chibon |
edfd4c |
|
|
Pierre-Yves Chibon |
21dd34 |
# Check if the closing notification was added
|
|
Pierre-Yves Chibon |
21dd34 |
output = self.app.get('/test/pull-request/1')
|
|
Pierre-Yves Chibon |
21dd34 |
self.assertIn(
|
|
Pierre-Yves Chibon |
be62f6 |
'<small>Pull-Request has been merged by pingou </small>',
|
|
Pierre-Yves Chibon |
be62f6 |
output.data)
|
|
Pierre-Yves Chibon |
21dd34 |
|
|
Farhaan Bukhsh |
3c36a9 |
@patch('pagure.lib.notify.send_email')
|
|
Farhaan Bukhsh |
3c36a9 |
def test_fork_edit_file(self, send_email):
|
|
Farhaan Bukhsh |
3c36a9 |
""" Test the fork_edit file endpoint. """
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
send_email.return_value = True
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
d90b91 |
# User not logged in
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/sources')
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 302)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
tests.create_projects(self.session)
|
|
Farhaan Bukhsh |
3c36a9 |
for folder in ['docs', 'tickets', 'requests', 'repos']:
|
|
Farhaan Bukhsh |
3c36a9 |
tests.create_projects_git(
|
|
Farhaan Bukhsh |
3c36a9 |
os.path.join(tests.HERE, folder), bare=True)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
user = tests.FakeUser()
|
|
Farhaan Bukhsh |
3c36a9 |
user.username = 'pingou'
|
|
Farhaan Bukhsh |
3c36a9 |
with tests.user_set(pagure.APP, user):
|
|
Farhaan Bukhsh |
d90b91 |
# Invalid request
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/source')
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 400)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.get('/new/')
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertIn('Create new Project', output.data)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
csrf_token = output.data.split(
|
|
Farhaan Bukhsh |
3c36a9 |
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
data = {
|
|
Farhaan Bukhsh |
3c36a9 |
'csrf_token': csrf_token,
|
|
Farhaan Bukhsh |
3c36a9 |
}
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
d90b91 |
# No files can be found since they are not added
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/sources',
|
|
Farhaan Bukhsh |
3c36a9 |
data=data, follow_redirects=True)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 404)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
user = tests.FakeUser()
|
|
Farhaan Bukhsh |
3c36a9 |
user.username = 'foo'
|
|
Farhaan Bukhsh |
3c36a9 |
with tests.user_set(pagure.APP, user):
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
data = {
|
|
Farhaan Bukhsh |
3c36a9 |
'csrf_token': csrf_token,
|
|
Farhaan Bukhsh |
3c36a9 |
}
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
d90b91 |
# Invalid request
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/sources',
|
|
Farhaan Bukhsh |
3c36a9 |
follow_redirects=True)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 400)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
63c088 |
# Add content to the repo
|
|
Farhaan Bukhsh |
3c36a9 |
tests.add_content_git_repo(os.path.join(
|
|
Farhaan Bukhsh |
3c36a9 |
pagure.APP.config['GIT_FOLDER'], 'test.git'))
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
tests.add_readme_git_repo(os.path.join(
|
|
Farhaan Bukhsh |
3c36a9 |
pagure.APP.config['GIT_FOLDER'], 'test.git'))
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
tests.add_binary_git_repo(
|
|
Farhaan Bukhsh |
3c36a9 |
os.path.join(
|
|
Farhaan Bukhsh |
3c36a9 |
pagure.APP.config['GIT_FOLDER'], 'test.git'), 'test.jpg')
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
63c088 |
# Check if button exists
|
|
Farhaan Bukhsh |
69bc30 |
output = self.app.get('/test/blob/master/f/sources')
|
|
Farhaan Bukhsh |
69bc30 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
69bc30 |
self.assertIn(
|
|
Farhaan Bukhsh |
69bc30 |
'Fork and Edit\n \n',
|
|
Farhaan Bukhsh |
69bc30 |
output.data)
|
|
Farhaan Bukhsh |
63c088 |
|
|
Farhaan Bukhsh |
d90b91 |
# Check fork-edit doesn't show for binary files
|
|
Farhaan Bukhsh |
63c088 |
output = self.app.get('/test/blob/master/f/test.jpg')
|
|
Farhaan Bukhsh |
63c088 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
63c088 |
self.assertNotIn(
|
|
Farhaan Bukhsh |
63c088 |
'Fork and Edit\n \n',
|
|
Farhaan Bukhsh |
63c088 |
output.data)
|
|
Farhaan Bukhsh |
63c088 |
|
|
Farhaan Bukhsh |
63c088 |
# Check for edit panel
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/sources',
|
|
Farhaan Bukhsh |
3c36a9 |
data=data, follow_redirects=True)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertIn(
|
|
Farhaan Bukhsh |
3c36a9 |
''
|
|
Farhaan Bukhsh |
3c36a9 |
' master'
|
|
Farhaan Bukhsh |
3c36a9 |
''
|
|
Farhaan Bukhsh |
3c36a9 |
' sources',
|
|
Farhaan Bukhsh |
3c36a9 |
output.data)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertIn(
|
|
Farhaan Bukhsh |
3c36a9 |
'<textarea id="textareaCode" name="content">foo\n bar</textarea>',
|
|
Farhaan Bukhsh |
3c36a9 |
output.data)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertIn(
|
|
Farhaan Bukhsh |
3c36a9 |
'\n Repo "test" '
|
|
Farhaan Bukhsh |
3c36a9 |
'cloned to "foo/test"', output.data)
|
|
Farhaan Bukhsh |
3c36a9 |
|
|
Farhaan Bukhsh |
3c36a9 |
# View what's supposed to be an image
|
|
Farhaan Bukhsh |
3c36a9 |
output = self.app.post('fork_edit/test/edit/master/f/test.jpg',
|
|
Farhaan Bukhsh |
3c36a9 |
data=data, follow_redirects=True)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertEqual(output.status_code, 400)
|
|
Farhaan Bukhsh |
3c36a9 |
self.assertIn('Cannot edit binary files ', output.data)
|
|
Pierre-Yves Chibon |
e64141 |
|
|
Farhaan Bukhsh |
d90b91 |
# Check fork-edit shows when user is not logged in
|
|
Farhaan Bukhsh |
d90b91 |
output = self.app.get('/test/blob/master/f/sources')
|
|
Farhaan Bukhsh |
d90b91 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
d90b91 |
self.assertIn(
|
|
Farhaan Bukhsh |
d90b91 |
'Fork and Edit\n \n',
|
|
Farhaan Bukhsh |
d90b91 |
output.data)
|
|
Farhaan Bukhsh |
d90b91 |
|
|
Farhaan Bukhsh |
d90b91 |
# Check if fork-edit shows for different user
|
|
Farhaan Bukhsh |
d90b91 |
user.username = 'pingou'
|
|
Farhaan Bukhsh |
d90b91 |
with tests.user_set(pagure.APP, user):
|
|
Farhaan Bukhsh |
d90b91 |
|
|
Farhaan Bukhsh |
d90b91 |
# Check if button exists
|
|
Farhaan Bukhsh |
d90b91 |
output = self.app.get('/test/blob/master/f/sources')
|
|
Farhaan Bukhsh |
d90b91 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
d90b91 |
self.assertIn(
|
|
Farhaan Bukhsh |
d90b91 |
'Fork and Edit\n \n',
|
|
Farhaan Bukhsh |
d90b91 |
output.data)
|
|
Farhaan Bukhsh |
d90b91 |
|
|
Farhaan Bukhsh |
d90b91 |
# Check fork-edit doesn't show for binary
|
|
Farhaan Bukhsh |
d90b91 |
output = self.app.get('/test/blob/master/f/test.jpg')
|
|
Farhaan Bukhsh |
d90b91 |
self.assertEqual(output.status_code, 200)
|
|
Farhaan Bukhsh |
d90b91 |
self.assertNotIn(
|
|
Farhaan Bukhsh |
d90b91 |
'Fork and Edit\n \n',
|
|
Farhaan Bukhsh |
d90b91 |
output.data)
|
|
Farhaan Bukhsh |
d90b91 |
|
|
Farhaan Bukhsh |
d90b91 |
|
|
Pierre-Yves Chibon |
9347b5 |
if __name__ == '__main__':
|
|
Pierre-Yves Chibon |
9347b5 |
SUITE = unittest.TestLoader().loadTestsFromTestCase(PagureFlaskForktests)
|
|
Pierre-Yves Chibon |
9347b5 |
unittest.TextTestRunner(verbosity=2).run(SUITE)
|