##// END OF EJS Templates
rhodecode.js: fix indentation
rhodecode.js: fix indentation

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4158:e4848cd9 rhodecode-2.2.5-gpl
Show More
test_forks.py
229 lines | 8.1 KiB | text/x-python | PythonLexer
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 # -*- coding: utf-8 -*-
added tests for forks and followers pages
r1375 from rhodecode.tests import *
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 from rhodecode.tests.fixture import Fixture
added tests for forks and followers pages
r1375
from rhodecode.model.db import Repository
fixed missing permissions check on forks page
r2176 from rhodecode.model.repo import RepoModel
from rhodecode.model.user import UserModel
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 from rhodecode.model.meta import Session
fixed missing permissions check on forks page
r2176
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 fixture = Fixture()
added tests for forks and followers pages
r1375
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 from rhodecode.tests import *
class _BaseTest(TestController):
"""
Write all tests here
"""
REPO = None
REPO_TYPE = None
NEW_REPO = None
REPO_FORK = None
@classmethod
def setup_class(cls):
pass
@classmethod
def teardown_class(cls):
pass
added tests for forks and followers pages
r1375
fixed missing permissions check on forks page
r2176 def setUp(self):
self.username = u'forkuser'
self.password = u'qweqwe'
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 self.u1 = fixture.create_user(self.username, password=self.password,
email=u'fork_king@rhodecode.org')
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 Session().commit()
fixed missing permissions check on forks page
r2176
def tearDown(self):
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 Session().delete(self.u1)
Session().commit()
fixed missing permissions check on forks page
r2176
added tests for forks and followers pages
r1375 def test_index(self):
self.log_user()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
added tests for forks and followers pages
r1375 response = self.app.get(url(controller='forks', action='forks',
repo_name=repo_name))
Use only mustcontain for testing response body
r3646 response.mustcontain("""There are no forks yet""")
added tests for forks and followers pages
r1375
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 def test_no_permissions_to_fork(self):
usr = self.log_user(TEST_USER_REGULAR_LOGIN,
TEST_USER_REGULAR_PASS)['user_id']
user_model = UserModel()
user_model.revoke_perm(usr, 'hg.fork.repository')
user_model.grant_perm(usr, 'hg.fork.none')
u = UserModel().get(usr)
u.inherit_default_permissions = False
Session().commit()
# try create a fork
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 self.app.post(url(controller='forks', action='fork_create',
repo_name=repo_name), {}, status=403)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 def test_index_with_fork(self):
added tests for forks and followers pages
r1375 self.log_user()
# create a fork
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 fork_name = self.REPO_FORK
added tests for forks and followers pages
r1375 description = 'fork of vcs test'
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
- refactoring to overcome poor usage of global pylons config...
r1723 org_repo = Repository.get_by_repo_name(repo_name)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 creation_args = {
'repo_name': fork_name,
'repo_group': '',
'fork_parent_id': org_repo.repo_id,
'repo_type': self.REPO_TYPE,
'description': description,
'private': 'False',
'landing_rev': 'rev:tip'}
self.app.post(url(controller='forks', action='fork_create',
repo_name=repo_name), creation_args)
added tests for forks and followers pages
r1375
response = self.app.get(url(controller='forks', action='forks',
repo_name=repo_name))
Initial version of landing revisions ref #483...
r2459 response.mustcontain(
fixed tests
r3291 """<a href="/%s">%s</a>""" % (fork_name, fork_name)
Initial version of landing revisions ref #483...
r2459 )
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 # remove this fork
Initial version of landing revisions ref #483...
r2459 response = self.app.delete(url('repo', repo_name=fork_name))
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 def test_fork_create_into_group(self):
Initial version of landing revisions ref #483...
r2459 self.log_user()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 group = fixture.create_repo_group('vc')
group_id = group.group_id
fork_name = self.REPO_FORK
fork_name_full = 'vc/%s' % fork_name
Initial version of landing revisions ref #483...
r2459 description = 'fork of vcs test'
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
Initial version of landing revisions ref #483...
r2459 org_repo = Repository.get_by_repo_name(repo_name)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 creation_args = {
'repo_name': fork_name,
'repo_group': group_id,
'fork_parent_id': org_repo.repo_id,
'repo_type': self.REPO_TYPE,
'description': description,
'private': 'False',
'landing_rev': 'rev:tip'}
self.app.post(url(controller='forks', action='fork_create',
repo_name=repo_name), creation_args)
repo = Repository.get_by_repo_name(fork_name_full)
assert repo.fork.repo_name == self.REPO
Initial version of landing revisions ref #483...
r2459
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 ## run the check page that triggers the flash message
response = self.app.get(url('repo_check_home', repo_name=fork_name_full))
#test if we have a message that fork is ok
self.checkSessionFlash(response,
'Forked repository %s as <a href="/%s">%s</a>'
% (repo_name, fork_name_full, fork_name_full))
#test if the fork was created in the database
fork_repo = Session().query(Repository)\
.filter(Repository.repo_name == fork_name_full).one()
Initial version of landing revisions ref #483...
r2459
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 self.assertEqual(fork_repo.repo_name, fork_name_full)
self.assertEqual(fork_repo.fork.repo_name, repo_name)
added tests for forks and followers pages
r1375
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 # test if the repository is visible in the list ?
response = self.app.get(url('summary_home', repo_name=fork_name_full))
response.mustcontain(fork_name_full)
response.mustcontain(self.REPO_TYPE)
response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name))
fixture.destroy_repo(fork_name_full)
fixture.destroy_repo_group(group_id)
added tests for forks and followers pages
r1375
- refactoring to overcome poor usage of global pylons config...
r1723 def test_z_fork_create(self):
self.log_user()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 fork_name = self.REPO_FORK
- refactoring to overcome poor usage of global pylons config...
r1723 description = 'fork of vcs test'
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
- refactoring to overcome poor usage of global pylons config...
r1723 org_repo = Repository.get_by_repo_name(repo_name)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 creation_args = {
'repo_name': fork_name,
'repo_group': '',
'fork_parent_id': org_repo.repo_id,
'repo_type': self.REPO_TYPE,
'description': description,
'private': 'False',
'landing_rev': 'rev:tip'}
self.app.post(url(controller='forks', action='fork_create',
repo_name=repo_name), creation_args)
repo = Repository.get_by_repo_name(self.REPO_FORK)
assert repo.fork.repo_name == self.REPO
- refactoring to overcome poor usage of global pylons config...
r1723
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 ## run the check page that triggers the flash message
response = self.app.get(url('repo_check_home', repo_name=fork_name))
- refactoring to overcome poor usage of global pylons config...
r1723 #test if we have a message that fork is ok
Initial version of landing revisions ref #483...
r2459 self.checkSessionFlash(response,
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 'Forked repository %s as <a href="/%s">%s</a>'
Repo size - show just the size without duplicating text...
r3550 % (repo_name, fork_name, fork_name))
- refactoring to overcome poor usage of global pylons config...
r1723
#test if the fork was created in the database
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 fork_repo = Session().query(Repository)\
- refactoring to overcome poor usage of global pylons config...
r1723 .filter(Repository.repo_name == fork_name).one()
self.assertEqual(fork_repo.repo_name, fork_name)
self.assertEqual(fork_repo.fork.repo_name, repo_name)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 # test if the repository is visible in the list ?
response = self.app.get(url('summary_home', repo_name=fork_name))
response.mustcontain(fork_name)
response.mustcontain(self.REPO_TYPE)
response.mustcontain('Fork of "<a href="/%s">%s</a>"' % (repo_name, repo_name))
fixed missing permissions check on forks page
r2176
def test_zz_fork_permission_page(self):
usr = self.log_user(self.username, self.password)['user_id']
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
fixed missing permissions check on forks page
r2176
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 forks = Repository.query()\
.filter(Repository.repo_type == self.REPO_TYPE)\
.filter(Repository.fork_id != None).all()
fixed missing permissions check on forks page
r2176 self.assertEqual(1, len(forks))
# set read permissions for this
RepoModel().grant_user_permission(repo=forks[0],
user=usr,
perm='repository.read')
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 Session().commit()
fixed missing permissions check on forks page
r2176
response = self.app.get(url(controller='forks', action='forks',
repo_name=repo_name))
response.mustcontain('<div style="padding:5px 3px 3px 42px;">fork of vcs test</div>')
def test_zzz_fork_permission_page(self):
usr = self.log_user(self.username, self.password)['user_id']
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 repo_name = self.REPO
fixed missing permissions check on forks page
r2176
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 forks = Repository.query()\
.filter(Repository.repo_type == self.REPO_TYPE)\
.filter(Repository.fork_id != None).all()
fixed missing permissions check on forks page
r2176 self.assertEqual(1, len(forks))
# set none
RepoModel().grant_user_permission(repo=forks[0],
user=usr, perm='repository.none')
RhodeCode now has a option to explicitly set forking permissions. ref #508...
r2709 Session().commit()
fixed missing permissions check on forks page
r2176 # fork shouldn't be there
response = self.app.get(url(controller='forks', action='forks',
repo_name=repo_name))
response.mustcontain('There are no forks yet')
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116
class TestGIT(_BaseTest):
REPO = GIT_REPO
NEW_REPO = NEW_GIT_REPO
REPO_TYPE = 'git'
REPO_FORK = GIT_FORK
class TestHG(_BaseTest):
REPO = HG_REPO
NEW_REPO = NEW_HG_REPO
REPO_TYPE = 'hg'
REPO_FORK = HG_FORK