|
Pierre-Yves Chibon |
317b75 |
# -*- coding: utf-8 -*-
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
"""
|
|
Pierre-Yves Chibon |
317b75 |
(c) 2016 - Copyright Red Hat Inc
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
Authors:
|
|
Pierre-Yves Chibon |
317b75 |
Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
"""
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
__requires__ = ['SQLAlchemy >= 0.8']
|
|
Pierre-Yves Chibon |
317b75 |
import pkg_resources
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
import json
|
|
Pierre-Yves Chibon |
317b75 |
import unittest
|
|
Pierre-Yves Chibon |
317b75 |
import shutil
|
|
Pierre-Yves Chibon |
317b75 |
import sys
|
|
Pierre-Yves Chibon |
317b75 |
import os
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
import pygit2
|
|
Pierre-Yves Chibon |
317b75 |
from mock import patch
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Pierre-Yves Chibon |
317b75 |
os.path.abspath(__file__)), '..'))
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
import pagure.lib
|
|
Pierre-Yves Chibon |
317b75 |
import tests
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
class PagureFlaskPluginDefaultHooktests(tests.Modeltests):
|
|
Pierre-Yves Chibon |
317b75 |
""" Tests for default_hook plugin of pagure """
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
def test_plugin_default_ui(self):
|
|
Pierre-Yves Chibon |
317b75 |
""" Test the default hook plugin on/off endpoint. """
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
tests.create_projects(self.session)
|
|
Patrick Uiterwijk |
170974 |
tests.create_projects_git(os.path.join(self.path, 'repos'))
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
user = tests.FakeUser(username='pingou')
|
|
Pierre-Yves Chibon |
b130e5 |
with tests.user_set(self.app.application, user):
|
|
Pierre-Yves Chibon |
317b75 |
output = self.app.get('/test/settings/default')
|
|
Pierre-Yves Chibon |
317b75 |
self.assertEqual(output.status_code, 403)
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
def test_plugin_default_install(self):
|
|
Pierre-Yves Chibon |
317b75 |
""" Check that the default plugin is correctly installed when a
|
|
Pierre-Yves Chibon |
317b75 |
project is created.
|
|
Pierre-Yves Chibon |
317b75 |
"""
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Aurélien Bompard |
a7f281 |
task = pagure.lib.new_project(
|
|
Pierre-Yves Chibon |
317b75 |
self.session,
|
|
Pierre-Yves Chibon |
317b75 |
user='pingou',
|
|
Pierre-Yves Chibon |
317b75 |
name='test',
|
|
Pierre-Yves Chibon |
317b75 |
blacklist=[],
|
|
Pierre-Yves Chibon |
317b75 |
allowed_prefix=[],
|
|
Patrick Uiterwijk |
170974 |
gitfolder=os.path.join(self.path, 'repos'),
|
|
Pierre-Yves Chibon |
317b75 |
docfolder=os.path.join(self.path, 'docs'),
|
|
Pierre-Yves Chibon |
317b75 |
ticketfolder=os.path.join(self.path, 'tickets'),
|
|
Pierre-Yves Chibon |
317b75 |
requestfolder=os.path.join(self.path, 'requests'),
|
|
Pierre-Yves Chibon |
317b75 |
description=None,
|
|
Pierre-Yves Chibon |
317b75 |
url=None, avatar_email=None,
|
|
Pierre-Yves Chibon |
317b75 |
parent_id=None,
|
|
Pierre-Yves Chibon |
317b75 |
add_readme=False,
|
|
Pierre-Yves Chibon |
317b75 |
userobj=None,
|
|
Pierre-Yves Chibon |
317b75 |
prevent_40_chars=False,
|
|
Pierre-Yves Chibon |
317b75 |
namespace=None
|
|
Pierre-Yves Chibon |
317b75 |
)
|
|
Aurélien Bompard |
a7f281 |
self.assertEqual(task.get(),
|
|
Pierre-Yves Chibon |
b130e5 |
{'endpoint': 'ui_ns.view_repo',
|
|
Patrick Uiterwijk |
170974 |
'repo': 'test',
|
|
Patrick Uiterwijk |
170974 |
'namespace': None})
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
self.assertTrue(os.path.exists(os.path.join(
|
|
Patrick Uiterwijk |
170974 |
self.path, 'repos', 'test.git', 'hooks', 'post-receive.default')))
|
|
Pierre-Yves Chibon |
317b75 |
self.assertTrue(os.path.exists(os.path.join(
|
|
Patrick Uiterwijk |
170974 |
self.path, 'repos', 'test.git', 'hooks', 'post-receive')))
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
|
|
Pierre-Yves Chibon |
317b75 |
if __name__ == '__main__':
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|