本文整理汇总了Python中kallithea.model.db.RepoGroup.url_sep方法的典型用法代码示例。如果您正苦于以下问题:Python RepoGroup.url_sep方法的具体用法?Python RepoGroup.url_sep怎么用?Python RepoGroup.url_sep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kallithea.model.db.RepoGroup
的用法示例。
在下文中一共展示了RepoGroup.url_sep方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_in_group
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_create_in_group(self):
self.log_user()
## create GROUP
group_name = 'sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description='test',
owner=TEST_USER_ADMIN_LOGIN)
Session().commit()
repo_name = 'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = 'description for newly created repo'
response = self.app.post(url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
repo_group=gr.group_id,
_authentication_token=self.authentication_token()))
## run the check page that triggers the flash message
response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
self.assertEqual(response.json, {u'result': True})
self.checkSessionFlash(response,
'Created repository <a href="/%s">%s</a>'
% (repo_name_full, repo_name_full))
# test if the repo was created in the database
new_repo = Session().query(Repository)\
.filter(Repository.repo_name == repo_name_full).one()
new_repo_id = new_repo.repo_id
self.assertEqual(new_repo.repo_name, repo_name_full)
self.assertEqual(new_repo.description, description)
# test if the repository is visible in the list ?
response = self.app.get(url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
inherited_perms = UserRepoToPerm.query()\
.filter(UserRepoToPerm.repository_id == new_repo_id).all()
self.assertEqual(len(inherited_perms), 1)
# test if the repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
except vcs.exceptions.VCSError:
RepoGroupModel().delete(group_name)
Session().commit()
self.fail('no repo %s in filesystem' % repo_name)
RepoModel().delete(repo_name_full)
RepoGroupModel().delete(group_name)
Session().commit()
示例2: test_repo_in_group_permissions
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_repo_in_group_permissions(self):
self.g1 = fixture.create_repo_group(u'group1', skip_if_exists=True)
self.g2 = fixture.create_repo_group(u'group2', skip_if_exists=True)
# both perms should be read !
u1_auth = AuthUser(user_id=self.u1.user_id)
assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
a1_auth = AuthUser(user_id=self.anon.user_id)
assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
#Change perms to none for both groups
RepoGroupModel().grant_user_permission(repo_group=self.g1,
user=self.anon,
perm='group.none')
RepoGroupModel().grant_user_permission(repo_group=self.g2,
user=self.anon,
perm='group.none')
u1_auth = AuthUser(user_id=self.u1.user_id)
assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
a1_auth = AuthUser(user_id=self.anon.user_id)
assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
# add repo to group
name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm'])
self.test_repo = fixture.create_repo(name=name,
repo_type='hg',
repo_group=self.g1,
cur_user=self.u1,)
u1_auth = AuthUser(user_id=self.u1.user_id)
assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
a1_auth = AuthUser(user_id=self.anon.user_id)
assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
#grant permission for u2 !
RepoGroupModel().grant_user_permission(repo_group=self.g1, user=self.u2,
perm='group.read')
RepoGroupModel().grant_user_permission(repo_group=self.g2, user=self.u2,
perm='group.read')
Session().commit()
assert self.u1 != self.u2
#u1 and anon should have not change perms while u2 should !
u1_auth = AuthUser(user_id=self.u1.user_id)
assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
u2_auth = AuthUser(user_id=self.u2.user_id)
assert u2_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
a1_auth = AuthUser(user_id=self.anon.user_id)
assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
示例3: test_subgrouping_with_repo
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_subgrouping_with_repo(self):
g1 = fixture.create_repo_group(u'g1')
g2 = fixture.create_repo_group(u'g2')
# create new repo
r = fixture.create_repo(u'john')
assert r.repo_name == 'john'
# put repo into group
r = _update_repo(u'john', repo_group=g1.group_id)
Session().commit()
assert r.repo_name == 'g1/john'
_update_repo_group(g1.group_id, u'g1', parent_id=g2.group_id)
assert self.__check_path('g2', 'g1')
# test repo
assert r.repo_name == RepoGroup.url_sep().join(['g2', 'g1',
r.just_name])
示例4: test_subgrouping_with_repo
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_subgrouping_with_repo(self):
g1 = fixture.create_repo_group('g1')
g2 = fixture.create_repo_group('g2')
# create new repo
r = fixture.create_repo('john')
self.assertEqual(r.repo_name, 'john')
# put repo into group
r = _update_repo('john', repo_group=g1.group_id)
Session().commit()
self.assertEqual(r.repo_name, 'g1/john')
_update_group(g1.group_id, 'g1', parent_id=g2.group_id)
self.assertTrue(self.__check_path('g2', 'g1'))
# test repo
self.assertEqual(r.repo_name, RepoGroup.url_sep().join(['g2', 'g1',
r.just_name]))
示例5: _delete_group
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def _delete_group(self, group, force_delete=False):
"""
Deletes a group from a filesystem
:param group: instance of group from database
:param force_delete: use shutil rmtree to remove all objects
"""
paths = group.full_path.split(RepoGroup.url_sep())
paths = os.sep.join(paths)
rm_path = os.path.join(self.repos_path, paths)
log.info("Removing group %s" % (rm_path))
# delete only if that path really exists
if os.path.isdir(rm_path):
if force_delete:
shutil.rmtree(rm_path)
else:
#archive that group`
_now = datetime.datetime.now()
_ms = str(_now.microsecond).rjust(6, '0')
_d = 'rm__%s_GROUP_%s' % (_now.strftime('%Y%m%d_%H%M%S_' + _ms),
group.name)
shutil.move(rm_path, os.path.join(self.repos_path, _d))
示例6: test_create_in_group_without_needed_permissions
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_create_in_group_without_needed_permissions(self):
usr = self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
# avoid spurious RepoGroup DetachedInstanceError ...
authentication_token = self.authentication_token()
# revoke
user_model = UserModel()
# disable fork and create on default user
user_model.revoke_perm(User.DEFAULT_USER, 'hg.create.repository')
user_model.grant_perm(User.DEFAULT_USER, 'hg.create.none')
user_model.revoke_perm(User.DEFAULT_USER, 'hg.fork.repository')
user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none')
# disable on regular user
user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none')
user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
Session().commit()
## create GROUP
group_name = 'reg_sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description='test',
owner=TEST_USER_ADMIN_LOGIN)
Session().commit()
group_name_allowed = 'reg_sometest_allowed_%s' % self.REPO_TYPE
gr_allowed = RepoGroupModel().create(group_name=group_name_allowed,
group_description='test',
owner=TEST_USER_REGULAR_LOGIN)
Session().commit()
repo_name = 'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = 'description for newly created repo'
response = self.app.post(url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
repo_group=gr.group_id,
_authentication_token=authentication_token))
response.mustcontain('Invalid value')
# user is allowed to create in this group
repo_name = 'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name])
description = 'description for newly created repo'
response = self.app.post(url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
repo_group=gr_allowed.group_id,
_authentication_token=authentication_token))
## run the check page that triggers the flash message
response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
self.assertEqual(response.json, {u'result': True})
self.checkSessionFlash(response,
'Created repository <a href="/%s">%s</a>'
% (repo_name_full, repo_name_full))
# test if the repo was created in the database
new_repo = Session().query(Repository)\
.filter(Repository.repo_name == repo_name_full).one()
new_repo_id = new_repo.repo_id
self.assertEqual(new_repo.repo_name, repo_name_full)
self.assertEqual(new_repo.description, description)
# test if the repository is visible in the list ?
response = self.app.get(url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
inherited_perms = UserRepoToPerm.query()\
.filter(UserRepoToPerm.repository_id == new_repo_id).all()
self.assertEqual(len(inherited_perms), 1)
# test if the repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
except vcs.exceptions.VCSError:
RepoGroupModel().delete(group_name)
Session().commit()
self.fail('no repo %s in filesystem' % repo_name)
RepoModel().delete(repo_name_full)
RepoGroupModel().delete(group_name)
RepoGroupModel().delete(group_name_allowed)
Session().commit()
示例7: test_create_in_group_inherit_permissions
# 需要导入模块: from kallithea.model.db import RepoGroup [as 别名]
# 或者: from kallithea.model.db.RepoGroup import url_sep [as 别名]
def test_create_in_group_inherit_permissions(self):
self.log_user()
## create GROUP
group_name = 'sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description='test',
owner=TEST_USER_ADMIN_LOGIN)
perm = Permission.get_by_key('repository.write')
RepoGroupModel().grant_user_permission(gr, TEST_USER_REGULAR_LOGIN, perm)
## add repo permissions
Session().commit()
repo_name = 'ingroup_inherited_%s' % self.REPO_TYPE
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = 'description for newly created repo'
response = self.app.post(url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
repo_group=gr.group_id,
repo_copy_permissions=True))
## run the check page that triggers the flash message
response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
self.checkSessionFlash(response,
'Created repository <a href="/%s">%s</a>'
% (repo_name_full, repo_name_full))
# test if the repo was created in the database
new_repo = Session().query(Repository)\
.filter(Repository.repo_name == repo_name_full).one()
new_repo_id = new_repo.repo_id
self.assertEqual(new_repo.repo_name, repo_name_full)
self.assertEqual(new_repo.description, description)
# test if the repository is visible in the list ?
response = self.app.get(url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
# test if the repository was created on filesystem
try:
vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
except vcs.exceptions.VCSError:
RepoGroupModel().delete(group_name)
Session().commit()
self.fail('no repo %s in filesystem' % repo_name)
#check if inherited permissiona are applied
inherited_perms = UserRepoToPerm.query()\
.filter(UserRepoToPerm.repository_id == new_repo_id).all()
self.assertEqual(len(inherited_perms), 2)
self.assertTrue(TEST_USER_REGULAR_LOGIN in [x.user.username
for x in inherited_perms])
self.assertTrue('repository.write' in [x.permission.permission_name
for x in inherited_perms])
RepoModel().delete(repo_name_full)
RepoGroupModel().delete(group_name)
Session().commit()