Mercurial > kallithea
comparison rhodecode/tests/models/common.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | 5067d6e826a5 |
children | da3c57422ee6 |
comparison
equal
deleted
inserted
replaced
4115:8b7294a804a0 | 4116:ffd45b185016 |
---|---|
1 from rhodecode.tests import * | 1 from rhodecode.tests import * |
2 from rhodecode.tests.fixture import Fixture | 2 from rhodecode.tests.fixture import Fixture |
3 | 3 |
4 from rhodecode.model.repos_group import ReposGroupModel | 4 from rhodecode.model.repo_group import RepoGroupModel |
5 from rhodecode.model.repo import RepoModel | 5 from rhodecode.model.repo import RepoModel |
6 from rhodecode.model.db import RepoGroup, Repository, User | 6 from rhodecode.model.db import RepoGroup, Repository, User |
7 from rhodecode.model.user import UserModel | 7 from rhodecode.model.user import UserModel |
8 | 8 |
9 from rhodecode.lib.auth import AuthUser | 9 from rhodecode.lib.auth import AuthUser |
13 fixture = Fixture() | 13 fixture = Fixture() |
14 | 14 |
15 | 15 |
16 def _destroy_project_tree(test_u1_id): | 16 def _destroy_project_tree(test_u1_id): |
17 Session.remove() | 17 Session.remove() |
18 repos_group = RepoGroup.get_by_group_name(group_name='g0') | 18 repo_group = RepoGroup.get_by_group_name(group_name='g0') |
19 for el in reversed(repos_group.recursive_groups_and_repos()): | 19 for el in reversed(repo_group.recursive_groups_and_repos()): |
20 if isinstance(el, Repository): | 20 if isinstance(el, Repository): |
21 RepoModel().delete(el) | 21 RepoModel().delete(el) |
22 elif isinstance(el, RepoGroup): | 22 elif isinstance(el, RepoGroup): |
23 ReposGroupModel().delete(el, force_delete=True) | 23 RepoGroupModel().delete(el, force_delete=True) |
24 | 24 |
25 u = User.get(test_u1_id) | 25 u = User.get(test_u1_id) |
26 Session().delete(u) | 26 Session().delete(u) |
27 Session().commit() | 27 Session().commit() |
28 | 28 |
54 """ | 54 """ |
55 test_u1 = UserModel().create_or_update( | 55 test_u1 = UserModel().create_or_update( |
56 username=u'test_u1', password=u'qweqwe', | 56 username=u'test_u1', password=u'qweqwe', |
57 email=u'test_u1@rhodecode.org', firstname=u'test_u1', lastname=u'test_u1' | 57 email=u'test_u1@rhodecode.org', firstname=u'test_u1', lastname=u'test_u1' |
58 ) | 58 ) |
59 g0 = fixture.create_group('g0') | 59 g0 = fixture.create_repo_group('g0') |
60 g0_1 = fixture.create_group('g0_1', group_parent_id=g0) | 60 g0_1 = fixture.create_repo_group('g0_1', group_parent_id=g0) |
61 g0_1_1 = fixture.create_group('g0_1_1', group_parent_id=g0_1) | 61 g0_1_1 = fixture.create_repo_group('g0_1_1', group_parent_id=g0_1) |
62 g0_1_1_r1 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r1', repos_group=g0_1_1) | 62 g0_1_1_r1 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r1', repo_group=g0_1_1) |
63 g0_1_1_r2 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r2', repos_group=g0_1_1) | 63 g0_1_1_r2 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r2', repo_group=g0_1_1) |
64 g0_1_r1 = fixture.create_repo('g0/g0_1/g0_1_r1', repos_group=g0_1) | 64 g0_1_r1 = fixture.create_repo('g0/g0_1/g0_1_r1', repo_group=g0_1) |
65 g0_2 = fixture.create_group('g0_2', group_parent_id=g0) | 65 g0_2 = fixture.create_repo_group('g0_2', group_parent_id=g0) |
66 g0_2_r1 = fixture.create_repo('g0/g0_2/g0_2_r1', repos_group=g0_2) | 66 g0_2_r1 = fixture.create_repo('g0/g0_2/g0_2_r1', repo_group=g0_2) |
67 g0_2_r2 = fixture.create_repo('g0/g0_2/g0_2_r2', repos_group=g0_2) | 67 g0_2_r2 = fixture.create_repo('g0/g0_2/g0_2_r2', repo_group=g0_2) |
68 g0_3 = fixture.create_group('g0_3', group_parent_id=g0) | 68 g0_3 = fixture.create_repo_group('g0_3', group_parent_id=g0) |
69 g0_3_r1 = fixture.create_repo('g0/g0_3/g0_3_r1', repos_group=g0_3) | 69 g0_3_r1 = fixture.create_repo('g0/g0_3/g0_3_r1', repo_group=g0_3) |
70 g0_3_r2_private = fixture.create_repo('g0/g0_3/g0_3_r1_private', | 70 g0_3_r2_private = fixture.create_repo('g0/g0_3/g0_3_r1_private', |
71 repos_group=g0_3, repo_private=True) | 71 repo_group=g0_3, repo_private=True) |
72 return test_u1 | 72 return test_u1 |
73 | 73 |
74 | 74 |
75 def expected_count(group_name, objects=False): | 75 def expected_count(group_name, objects=False): |
76 repos_group = RepoGroup.get_by_group_name(group_name=group_name) | 76 repo_group = RepoGroup.get_by_group_name(group_name=group_name) |
77 objs = repos_group.recursive_groups_and_repos() | 77 objs = repo_group.recursive_groups_and_repos() |
78 if objects: | 78 if objects: |
79 return objs | 79 return objs |
80 return len(objs) | 80 return len(objs) |
81 | 81 |
82 | 82 |
83 def _check_expected_count(items, repo_items, expected): | 83 def _check_expected_count(items, repo_items, expected): |
84 should_be = len(items + repo_items) | 84 should_be = len(items + repo_items) |
85 there_are = len(expected) | 85 there_are = len(expected) |
86 assert should_be == there_are, ('%s != %s' % ((items + repo_items), expected)) | 86 assert should_be == there_are, ('%s != %s' % ((items + repo_items), expected)) |
87 | 87 |
88 | 88 |
89 def check_tree_perms(obj_name, repo_perm, prefix, expected_perm): | 89 def check_tree_perms(obj_name, repo_perm, prefix, expected_perm): |
90 assert repo_perm == expected_perm, ('obj:`%s` got perm:`%s` should:`%s`' | 90 assert repo_perm == expected_perm, ('obj:`%s` got perm:`%s` should:`%s`' |
91 % (obj_name, repo_perm, expected_perm)) | 91 % (obj_name, repo_perm, expected_perm)) |
92 | 92 |
93 | 93 |
94 def _get_perms(filter_='', recursive=True, key=None, test_u1_id=None): | 94 def _get_perms(filter_='', recursive=None, key=None, test_u1_id=None): |
95 test_u1 = AuthUser(user_id=test_u1_id) | 95 test_u1 = AuthUser(user_id=test_u1_id) |
96 for k, v in test_u1.permissions[key].items(): | 96 for k, v in test_u1.permissions[key].items(): |
97 if recursive and k.startswith(filter_): | 97 if recursive in ['all', 'repos', 'groups'] and k.startswith(filter_): |
98 yield k, v | 98 yield k, v |
99 elif not recursive: | 99 elif recursive in ['none']: |
100 if k == filter_: | 100 if k == filter_: |
101 yield k, v | 101 yield k, v |