##// END OF EJS Templates
tests: merge test_repo_groups.py into test_admin_repo_groups.py...
Thomas De Schampheleire -
r8710:2ef4f7c0 stable
parent child Browse files
Show More
@@ -1,26 +1,99 b''
1 from kallithea.model import meta
1 from kallithea.model import meta
2 from kallithea.model.repo_group import RepoGroupModel
2 from kallithea.model.repo_group import RepoGroupModel
3 from kallithea.tests import base
3 from kallithea.tests import base
4 from kallithea.tests.fixture import Fixture
4 from kallithea.tests.fixture import Fixture
5
5
6
6
7 fixture = Fixture()
7 fixture = Fixture()
8
8
9
9
10 class TestRepoGroupsController(base.TestController):
10 class TestRepoGroupsController(base.TestController):
11
11
12 def test_index(self):
13 self.log_user()
14 response = self.app.get(base.url('repos_groups'))
15 response.mustcontain('"records": []')
16
17 def test_new(self):
18 self.log_user()
19 response = self.app.get(base.url('new_repos_group'))
20
21 def test_create(self):
22 self.log_user()
23
24 group_name = 'foo'
25
26 # creation with form error
27 response = self.app.post(base.url('repos_groups'),
28 {'group_name': group_name,
29 '_session_csrf_secret_token': self.session_csrf_secret_token()})
30 response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
31 response.mustcontain('<!-- for: group_description -->')
32
33 # creation
34 response = self.app.post(base.url('repos_groups'),
35 {'group_name': group_name,
36 'group_description': 'lala',
37 'parent_group_id': '-1',
38 'group_copy_permissions': 'True',
39 '_session_csrf_secret_token': self.session_csrf_secret_token()})
40 self.checkSessionFlash(response, 'Created repository group %s' % group_name)
41
42 # edit form
43 response = self.app.get(base.url('edit_repo_group', group_name=group_name))
44 response.mustcontain('>lala<')
45
46 # edit with form error
47 response = self.app.post(base.url('update_repos_group', group_name=group_name),
48 {'group_name': group_name,
49 '_session_csrf_secret_token': self.session_csrf_secret_token()})
50 response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
51 response.mustcontain('<!-- for: group_description -->')
52
53 # edit
54 response = self.app.post(base.url('update_repos_group', group_name=group_name),
55 {'group_name': group_name,
56 'group_description': 'lolo',
57 '_session_csrf_secret_token': self.session_csrf_secret_token()})
58 self.checkSessionFlash(response, 'Updated repository group %s' % group_name)
59 response = response.follow()
60 response.mustcontain('name="group_name" type="text" value="%s"' % group_name)
61 response.mustcontain(no='<!-- for: group_description -->')
62 response.mustcontain('>lolo<')
63
64 # listing
65 response = self.app.get(base.url('repos_groups'))
66 response.mustcontain('raw_name": "%s"' % group_name)
67
68 # show
69 response = self.app.get(base.url('repos_group', group_name=group_name))
70 response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name)
71
72 # show ignores extra trailing slashes in the URL
73 response = self.app.get(base.url('repos_group', group_name='%s//' % group_name))
74 response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name)
75
76 # delete
77 response = self.app.post(base.url('delete_repo_group', group_name=group_name),
78 {'_session_csrf_secret_token': self.session_csrf_secret_token()})
79 self.checkSessionFlash(response, 'Removed repository group %s' % group_name)
80
81 def test_new_by_regular_user(self):
82 self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
83 response = self.app.get(base.url('new_repos_group'), status=403)
84
12 def test_case_insensitivity(self):
85 def test_case_insensitivity(self):
13 self.log_user()
86 self.log_user()
14 group_name = 'newgroup'
87 group_name = 'newgroup'
15 response = self.app.post(base.url('repos_groups'),
88 response = self.app.post(base.url('repos_groups'),
16 fixture._get_repo_group_create_params(group_name=group_name,
89 fixture._get_repo_group_create_params(group_name=group_name,
17 _session_csrf_secret_token=self.session_csrf_secret_token()))
90 _session_csrf_secret_token=self.session_csrf_secret_token()))
18 # try to create repo group with swapped case
91 # try to create repo group with swapped case
19 swapped_group_name = group_name.swapcase()
92 swapped_group_name = group_name.swapcase()
20 response = self.app.post(base.url('repos_groups'),
93 response = self.app.post(base.url('repos_groups'),
21 fixture._get_repo_group_create_params(group_name=swapped_group_name,
94 fixture._get_repo_group_create_params(group_name=swapped_group_name,
22 _session_csrf_secret_token=self.session_csrf_secret_token()))
95 _session_csrf_secret_token=self.session_csrf_secret_token()))
23 response.mustcontain('already exists')
96 response.mustcontain('already exists')
24
97
25 RepoGroupModel().delete(group_name)
98 RepoGroupModel().delete(group_name)
26 meta.Session().commit()
99 meta.Session().commit()
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now