|
Pierre-Yves Chibon |
65f7db |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
"""
|
|
Pierre-Yves Chibon |
65f7db |
(c) 2015 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
Authors:
|
|
Pierre-Yves Chibon |
65f7db |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
"""
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
67d1cc |
from __future__ import unicode_literals, absolute_import
|
|
Aurélien Bompard |
dcf6f6 |
|
|
Pierre-Yves Chibon |
65f7db |
import json
|
|
Pierre-Yves Chibon |
65f7db |
import unittest
|
|
Pierre-Yves Chibon |
65f7db |
import shutil
|
|
Pierre-Yves Chibon |
65f7db |
import sys
|
|
Pierre-Yves Chibon |
65f7db |
import tempfile
|
|
Pierre-Yves Chibon |
65f7db |
import os
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
import pygit2
|
|
Pierre-Yves Chibon |
65f7db |
from mock import patch
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Pierre-Yves Chibon |
65f7db |
os.path.abspath(__file__)), '..'))
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
930073 |
import pagure.lib.query
|
|
Pierre-Yves Chibon |
65f7db |
import tests
|
|
Pierre-Yves Chibon |
27a73d |
from pagure.lib.repo import PagureRepo
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Clement Verna |
109c4b |
class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest):
|
|
Pierre-Yves Chibon |
65f7db |
""" Tests for flask application when the git repo has no master branch.
|
|
Pierre-Yves Chibon |
65f7db |
"""
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
def set_up_git_repo(self):
|
|
Pierre-Yves Chibon |
65f7db |
""" Set up the git repo to play with. """
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
# Create a git repo to play with
|
|
Jeremy Cline |
20109f |
gitrepo = os.path.join(self.path, 'repos', 'test.git')
|
|
Pierre-Yves Chibon |
65f7db |
repo = pygit2.init_repository(gitrepo, bare=True)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
newpath = tempfile.mkdtemp(prefix='pagure-other-test')
|
|
Pierre-Yves Chibon |
65f7db |
repopath = os.path.join(newpath, 'test')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo = pygit2.clone_repository(gitrepo, repopath)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
# Create a file in that git repo
|
|
Pierre-Yves Chibon |
65f7db |
with open(os.path.join(repopath, 'sources'), 'w') as stream:
|
|
Pierre-Yves Chibon |
65f7db |
stream.write('foo\n bar')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.index.add('sources')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.index.write()
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
# Commits the files added
|
|
Pierre-Yves Chibon |
65f7db |
tree = clone_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
65f7db |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
65f7db |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
65f7db |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
65f7db |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.create_commit(
|
|
Pierre-Yves Chibon |
65f7db |
'refs/heads/feature', # the name of the reference to update
|
|
Pierre-Yves Chibon |
65f7db |
author,
|
|
Pierre-Yves Chibon |
65f7db |
committer,
|
|
Pierre-Yves Chibon |
65f7db |
'Add sources file for testing',
|
|
Pierre-Yves Chibon |
65f7db |
# binary string representing the tree object ID
|
|
Pierre-Yves Chibon |
65f7db |
tree,
|
|
Pierre-Yves Chibon |
65f7db |
# list of binary strings representing parents of the new commit
|
|
Pierre-Yves Chibon |
65f7db |
[]
|
|
Pierre-Yves Chibon |
65f7db |
)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
feature_branch = clone_repo.lookup_branch('feature')
|
|
Pierre-Yves Chibon |
65f7db |
first_commit = feature_branch.get_object().hex
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
# Second commit
|
|
Pierre-Yves Chibon |
65f7db |
with open(os.path.join(repopath, '.gitignore'), 'w') as stream:
|
|
Pierre-Yves Chibon |
65f7db |
stream.write('*~')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.index.add('.gitignore')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.index.write()
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
tree = clone_repo.index.write_tree()
|
|
Pierre-Yves Chibon |
65f7db |
author = pygit2.Signature(
|
|
Pierre-Yves Chibon |
65f7db |
'Alice Author', 'alice@authors.tld')
|
|
Pierre-Yves Chibon |
65f7db |
committer = pygit2.Signature(
|
|
Pierre-Yves Chibon |
65f7db |
'Cecil Committer', 'cecil@committers.tld')
|
|
Pierre-Yves Chibon |
65f7db |
clone_repo.create_commit(
|
|
Pierre-Yves Chibon |
07f8d0 |
'refs/heads/feature',
|
|
Pierre-Yves Chibon |
65f7db |
author,
|
|
Pierre-Yves Chibon |
65f7db |
committer,
|
|
Pierre-Yves Chibon |
65f7db |
'Add .gitignore file for testing',
|
|
Pierre-Yves Chibon |
65f7db |
# binary string representing the tree object ID
|
|
Pierre-Yves Chibon |
65f7db |
tree,
|
|
Pierre-Yves Chibon |
65f7db |
# list of binary strings representing parents of the new commit
|
|
Pierre-Yves Chibon |
65f7db |
[first_commit]
|
|
Pierre-Yves Chibon |
65f7db |
)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
refname = 'refs/heads/feature'
|
|
Pierre-Yves Chibon |
65f7db |
ori_remote = clone_repo.remotes[0]
|
|
Pierre-Yves Chibon |
27a73d |
PagureRepo.push(ori_remote, refname)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
shutil.rmtree(newpath)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
65f7db |
def test_view_repo(self, send_email):
|
|
Pierre-Yves Chibon |
65f7db |
""" Test the view_repo endpoint when the git repo has no master
|
|
Pierre-Yves Chibon |
65f7db |
branch.
|
|
Pierre-Yves Chibon |
65f7db |
"""
|
|
Pierre-Yves Chibon |
65f7db |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
65f7db |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
65f7db |
output = self.app.get('/test')
|
|
Pierre-Yves Chibon |
65f7db |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
# With git repo
|
|
Pierre-Yves Chibon |
65f7db |
output = self.app.get('/test')
|
|
Pierre-Yves Chibon |
65f7db |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<section class="no-readme">', output_text)</section>
|
|
Pierre-Yves Chibon |
d67415 |
self.assertIn(
|
|
Pierre-Yves Chibon |
a324b4 |
"The test project's README file is empty or unavailable.",
|
|
Aurélien Bompard |
626417 |
output_text)
|
|
Pierre-Yves Chibon |
d67415 |
self.assertEqual(
|
|
Aurélien Bompard |
626417 |
output_text.count('
|
|
Pierre-Yves Chibon |
d67415 |
0)
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
9071b6 |
'''
|
|
Pierre-Yves Chibon |
a5ec94 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
a5ec94 |
def test_view_repo_branch(self, send_email):
|
|
Pierre-Yves Chibon |
a5ec94 |
""" Test the view_repo_branch endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
a5ec94 |
master branch.
|
|
Pierre-Yves Chibon |
a5ec94 |
"""
|
|
Pierre-Yves Chibon |
a5ec94 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
a5ec94 |
|
|
Pierre-Yves Chibon |
a5ec94 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
a5ec94 |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
a5ec94 |
output = self.app.get('/test/branch/master')
|
|
Pierre-Yves Chibon |
a5ec94 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
a5ec94 |
|
|
Pierre-Yves Chibon |
a5ec94 |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
a5ec94 |
|
|
Pierre-Yves Chibon |
a5ec94 |
# With git repo
|
|
Pierre-Yves Chibon |
a5ec94 |
output = self.app.get('/test/branch/feature')
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
9071b6 |
print(output_text)
|
|
Pierre-Yves Chibon |
9071b6 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertIn('<section class="no-readme">', output_text)</section>
|
|
Pierre-Yves Chibon |
d67415 |
self.assertIn(
|
|
Pierre-Yves Chibon |
a324b4 |
"The test project's README file is empty or unavailable.",
|
|
Aurélien Bompard |
626417 |
output_text)
|
|
Pierre-Yves Chibon |
9071b6 |
'''
|
|
Pierre-Yves Chibon |
a5ec94 |
|
|
Pierre-Yves Chibon |
59857a |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
59857a |
def test_view_commits(self, send_email):
|
|
Pierre-Yves Chibon |
59857a |
""" Test the view_commits endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
59857a |
master branch.
|
|
Pierre-Yves Chibon |
59857a |
"""
|
|
Pierre-Yves Chibon |
59857a |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
59857a |
|
|
Pierre-Yves Chibon |
59857a |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
59857a |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
59857a |
output = self.app.get('/test/commits')
|
|
Pierre-Yves Chibon |
59857a |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
59857a |
|
|
Pierre-Yves Chibon |
59857a |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
59857a |
|
|
Pierre-Yves Chibon |
59857a |
# With git repo
|
|
Pierre-Yves Chibon |
59857a |
output = self.app.get('/test/commits')
|
|
Pierre-Yves Chibon |
59857a |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
59857a |
self.assertIn(
|
|
Pierre-Yves Chibon |
9071b6 |
'\n\n\n ',
|
|
Aurélien Bompard |
626417 |
output_text)
|
|
Pierre-Yves Chibon |
d67415 |
self.assertNotIn(
|
|
Aurélien Bompard |
626417 |
'', output_text)
|
|
Pierre-Yves Chibon |
59857a |
|
|
Pierre-Yves Chibon |
59857a |
output = self.app.get('/test/commits/feature')
|
|
Pierre-Yves Chibon |
59857a |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
d67415 |
self.assertIn(
|
|
Ryan Lerch |
eef090 |
'Commits 2',
|
|
Aurélien Bompard |
626417 |
output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('Add sources file for testing', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('Add .gitignore file for testing', output_text)
|
|
Pierre-Yves Chibon |
59857a |
self.assertNotIn(
|
|
Pierre-Yves Chibon |
9071b6 |
'\n\n\n ',
|
|
Pierre-Yves Chibon |
9071b6 |
output_text)
|
|
Pierre-Yves Chibon |
d67415 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
9071b6 |
output_text.count('class="list-group-item "'), 2)
|
|
Pierre-Yves Chibon |
59857a |
|
|
Pierre-Yves Chibon |
e5bc0d |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
e5bc0d |
def test_view_file(self, send_email):
|
|
Pierre-Yves Chibon |
e5bc0d |
""" Test the view_file endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
e5bc0d |
master branch.
|
|
Pierre-Yves Chibon |
e5bc0d |
"""
|
|
Pierre-Yves Chibon |
e5bc0d |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
e5bc0d |
|
|
Pierre-Yves Chibon |
e5bc0d |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
e5bc0d |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
e5bc0d |
output = self.app.get('/test/blob/master/f/sources')
|
|
Pierre-Yves Chibon |
e5bc0d |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
e5bc0d |
|
|
Pierre-Yves Chibon |
e5bc0d |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
e5bc0d |
|
|
Pierre-Yves Chibon |
e5bc0d |
# With git repo
|
|
Pierre-Yves Chibon |
e5bc0d |
output = self.app.get('/test/blob/master/f/sources')
|
|
Pierre-Yves Chibon |
e5bc0d |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
e5bc0d |
|
|
Pierre-Yves Chibon |
e5bc0d |
output = self.app.get('/test/blob/feature/f/sources')
|
|
Pierre-Yves Chibon |
e5bc0d |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Pierre-Yves Chibon |
e5bc0d |
self.assertIn(
|
|
Pierre-Yves Chibon |
557220 |
'''
|
|
Ryan Lerch |
0f2b01 |
|
|
Pierre-Yves Chibon |
9071b6 |
|
|
Pierre-Yves Chibon |
557220 |
|
|
Pierre-Yves Chibon |
9071b6 |
|
|
Pierre-Yves Chibon |
557220 |
feature
|
|
Pierre-Yves Chibon |
557220 |
|
|
Pierre-Yves Chibon |
557220 |
|
|
Pierre-Yves Chibon |
9071b6 |
|
|
Pierre-Yves Chibon |
9071b6 |
|
|
Pierre-Yves Chibon |
557220 |
sources
|
|
Pierre-Yves Chibon |
557220 |
|
|
Aurélien Bompard |
626417 |
''', output_text)
|
|
Pierre-Yves Chibon |
967e77 |
self.assertIn(
|
|
Pierre-Yves Chibon |
2d9829 |
'foo\n bar ',
|
|
Pierre-Yves Chibon |
2d9829 |
output_text
|
|
Pierre-Yves Chibon |
967e77 |
)
|
|
Pierre-Yves Chibon |
e5bc0d |
|
|
Pierre-Yves Chibon |
d908a9 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
d908a9 |
def test_view_raw_file(self, send_email):
|
|
Pierre-Yves Chibon |
d908a9 |
""" Test the view_raw_file endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
d908a9 |
master branch.
|
|
Pierre-Yves Chibon |
d908a9 |
"""
|
|
Pierre-Yves Chibon |
d908a9 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
d908a9 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
d908a9 |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/master')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/master/f/sources')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
d908a9 |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
d908a9 |
# With git repo
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/master')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/master/f/sources')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/feature')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
output_text = output.get_data(as_text=True)
|
|
Aurélien Bompard |
626417 |
self.assertIn('diff --git a/.gitignore b/.gitignore', output_text)
|
|
Aurélien Bompard |
626417 |
self.assertIn('+*~', output_text)
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
d908a9 |
output = self.app.get('/test/raw/feature/f/sources')
|
|
Pierre-Yves Chibon |
d908a9 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertEqual('foo\n bar', output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
d908a9 |
|
|
Pierre-Yves Chibon |
45cfa4 |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
45cfa4 |
def test_view_tree(self, send_email):
|
|
Pierre-Yves Chibon |
45cfa4 |
""" Test the view_tree endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
45cfa4 |
master branch.
|
|
Pierre-Yves Chibon |
45cfa4 |
"""
|
|
Pierre-Yves Chibon |
45cfa4 |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
45cfa4 |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
45cfa4 |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/master')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
45cfa4 |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
45cfa4 |
# With git repo
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/master')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertIn('No content found in this repository', output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/master/sources')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertIn('No content found in this repository', output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/feature')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertIn('', output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
45cfa4 |
output = self.app.get('/test/tree/feature/sources')
|
|
Pierre-Yves Chibon |
45cfa4 |
self.assertEqual(output.status_code, 200)
|
|
Aurélien Bompard |
626417 |
self.assertIn('No content found in this repository', output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
45cfa4 |
|
|
Pierre-Yves Chibon |
60fe0c |
@patch('pagure.lib.notify.send_email')
|
|
Pierre-Yves Chibon |
60fe0c |
def test_new_request_pull(self, send_email):
|
|
Pierre-Yves Chibon |
60fe0c |
""" Test the new_request_pull endpoint when the git repo has no
|
|
Pierre-Yves Chibon |
60fe0c |
master branch.
|
|
Pierre-Yves Chibon |
60fe0c |
"""
|
|
Pierre-Yves Chibon |
60fe0c |
send_email.return_value = True
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
60fe0c |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
60fe0c |
# Non-existant git repo
|
|
Pierre-Yves Chibon |
60fe0c |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
4fcf92 |
# (used to be 302 but seeing a diff is allowed even logged out)
|
|
Pierre-Yves Chibon |
4fcf92 |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
60fe0c |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
60fe0c |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
60fe0c |
self.assertEqual(output.status_code, 404)
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
60fe0c |
self.set_up_git_repo()
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
60fe0c |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
4fcf92 |
# (used to be 302 but seeing a diff is allowed even logged out)
|
|
Pierre-Yves Chibon |
4fcf92 |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
4fcf92 |
self.assertIn(
|
|
Pierre-Yves Chibon |
4fcf92 |
'Branch master could not be found in the target repo ',
|
|
Aurélien Bompard |
626417 |
output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
60fe0c |
user = tests.FakeUser()
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
60fe0c |
output = self.app.get('/test/diff/master..feature')
|
|
Pierre-Yves Chibon |
60fe0c |
self.assertEqual(output.status_code, 400)
|
|
Pierre-Yves Chibon |
60fe0c |
self.assertIn(
|
|
Pierre-Yves Chibon |
60fe0c |
'Branch master could not be found in the target repo ',
|
|
Aurélien Bompard |
626417 |
output.get_data(as_text=True))
|
|
Pierre-Yves Chibon |
60fe0c |
|
|
Pierre-Yves Chibon |
65f7db |
|
|
Pierre-Yves Chibon |
65f7db |
if __name__ == '__main__':
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|