Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_repos.py @ 3640:4f80df0d45c8 beta
unified flash msg tests
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 30 Mar 2013 16:17:56 +0100 |
parents | 10b4e34841a4 |
children | aef5f5ce5ead |
rev | line source |
---|---|
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
1 # -*- coding: utf-8 -*- |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
2 |
1037
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
3 import os |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
4 import urllib |
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
5 |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
6 from rhodecode.lib import vcs |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
7 from rhodecode.model.db import Repository, RepoGroup, UserRepoToPerm, User,\ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
8 Permission |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
9 from rhodecode.tests import * |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
10 from rhodecode.model.repos_group import ReposGroupModel |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
11 from rhodecode.model.repo import RepoModel |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
12 from rhodecode.model.meta import Session |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
13 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
14 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
15 def _get_permission_for_user(user, repo): |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
16 perm = UserRepoToPerm.query()\ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
17 .filter(UserRepoToPerm.repository == |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
18 Repository.get_by_repo_name(repo))\ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
19 .filter(UserRepoToPerm.user == User.get_by_username(user))\ |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
20 .all() |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
21 return perm |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
22 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
23 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
24 class TestAdminReposController(TestController): |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
25 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
26 def __make_repo(self): |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
27 pass |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
28 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
29 def test_index(self): |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
30 self.log_user() |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
31 response = self.app.get(url('repos')) |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
32 # Test response... |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
33 |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
34 def test_index_as_xml(self): |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
35 response = self.app.get(url('formatted_repos', format='xml')) |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
36 |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
37 def test_create_hg(self): |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
38 self.log_user() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
39 repo_name = NEW_HG_REPO |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
40 description = 'description for newly created repo' |
3057
79c5967a1e5c
whitespace and formatting
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
41 response = self.app.post(url('repos'), |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
42 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
43 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
44 repo_description=description)) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
45 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
46 'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
47 % (repo_name, repo_name)) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
48 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
49 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
50 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
51 .filter(Repository.repo_name == repo_name).one() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
52 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
53 self.assertEqual(new_repo.repo_name, repo_name) |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
54 self.assertEqual(new_repo.description, description) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
55 |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
56 #test if repository is visible in the list ? |
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
57 response = response.follow() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
58 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
59 response.mustcontain(repo_name) |
1037
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
60 |
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
61 #test if repository was created on filesystem |
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
62 try: |
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
63 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
64 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
65 self.fail('no repo %s in filesystem' % repo_name) |
1037
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
66 |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
67 def test_create_hg_non_ascii(self): |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
68 self.log_user() |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
69 non_ascii = "ąęł" |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
70 repo_name = "%s%s" % (NEW_HG_REPO, non_ascii) |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
71 repo_name_unicode = repo_name.decode('utf8') |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
72 description = 'description for newly created repo' + non_ascii |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
73 description_unicode = description.decode('utf8') |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
74 private = False |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
75 response = self.app.post(url('repos'), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
76 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
77 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
78 repo_description=description)) |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
79 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
80 u'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
81 % (urllib.quote(repo_name), repo_name_unicode)) |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
82 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
83 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
84 .filter(Repository.repo_name == repo_name_unicode).one() |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
85 |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
86 self.assertEqual(new_repo.repo_name, repo_name_unicode) |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
87 self.assertEqual(new_repo.description, description_unicode) |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
88 |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
89 #test if repository is visible in the list ? |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
90 response = response.follow() |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
91 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
92 response.mustcontain(repo_name) |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
93 |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
94 #test if repository was created on filesystem |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
95 try: |
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
96 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
97 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
98 self.fail('no repo %s in filesystem' % repo_name) |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
99 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
100 def test_create_hg_in_group(self): |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
101 self.log_user() |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
102 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
103 ## create GROUP |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
104 group_name = 'sometest' |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
105 gr = ReposGroupModel().create(group_name=group_name, |
3222
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3219
diff
changeset
|
106 group_description='test', |
b4daef4cc26d
Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents:
3219
diff
changeset
|
107 owner=TEST_USER_ADMIN_LOGIN) |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
108 self.Session().commit() |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
109 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
110 repo_name = 'ingroup' |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
111 repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
112 description = 'description for newly created repo' |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
113 response = self.app.post(url('repos'), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
114 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
115 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
116 repo_description=description, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
117 repo_group=gr.group_id,)) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
118 |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
119 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
120 'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
121 % (repo_name, repo_name)) |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
122 #test if the repo was created in the database |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
123 new_repo = self.Session().query(Repository)\ |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
124 .filter(Repository.repo_name == repo_name_full).one() |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
125 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
126 self.assertEqual(new_repo.repo_name, repo_name_full) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
127 self.assertEqual(new_repo.description, description) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
128 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
129 #test if repository is visible in the list ? |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
130 response = response.follow() |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
131 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
132 response.mustcontain(repo_name_full) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
133 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
134 #test if repository was created on filesystem |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
135 try: |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
136 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
137 except Exception: |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
138 ReposGroupModel().delete(group_name) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
139 self.Session().commit() |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
140 self.fail('no repo %s in filesystem' % repo_name) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
141 |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
142 RepoModel().delete(repo_name_full) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
143 ReposGroupModel().delete(group_name) |
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
144 self.Session().commit() |
1037
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
145 |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
146 def test_create_git(self): |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
147 self.log_user() |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
148 repo_name = NEW_GIT_REPO |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
149 description = 'description for newly created repo' |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
150 |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
151 response = self.app.post(url('repos'), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
152 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
153 repo_type='git', |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
154 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
155 repo_description=description)) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
156 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
157 'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
158 % (repo_name, repo_name)) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
159 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
160 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
161 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
162 .filter(Repository.repo_name == repo_name).one() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
163 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
164 self.assertEqual(new_repo.repo_name, repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
165 self.assertEqual(new_repo.description, description) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
166 |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
167 #test if repository is visible in the list ? |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
168 response = response.follow() |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
169 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
170 response.mustcontain(repo_name) |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
171 |
1037
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
172 #test if repository was created on filesystem |
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
173 try: |
b1d6478d4561
added repo creation filesystem test
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
174 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
175 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
176 self.fail('no repo %s in filesystem' % repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
177 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
178 def test_create_git_non_ascii(self): |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
179 self.log_user() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
180 non_ascii = "ąęł" |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
181 repo_name = "%s%s" % (NEW_GIT_REPO, non_ascii) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
182 repo_name_unicode = repo_name.decode('utf8') |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
183 description = 'description for newly created repo' + non_ascii |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
184 description_unicode = description.decode('utf8') |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
185 private = False |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
186 response = self.app.post(url('repos'), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
187 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
188 repo_type='git', |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
189 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
190 repo_description=description)) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
191 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
192 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
193 u'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
194 % (urllib.quote(repo_name), repo_name_unicode)) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
195 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
196 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
197 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
198 .filter(Repository.repo_name == repo_name_unicode).one() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
199 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
200 self.assertEqual(new_repo.repo_name, repo_name_unicode) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
201 self.assertEqual(new_repo.description, description_unicode) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
202 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
203 #test if repository is visible in the list ? |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
204 response = response.follow() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
205 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
206 response.mustcontain(repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
207 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
208 #test if repository was created on filesystem |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
209 try: |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
210 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
211 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
212 self.fail('no repo %s in filesystem' % repo_name) |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
213 |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
214 def test_update(self): |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
215 response = self.app.put(url('repo', repo_name=HG_REPO)) |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
216 |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
217 def test_update_browser_fakeout(self): |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
218 response = self.app.post(url('repo', repo_name=HG_REPO), |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
219 params=dict(_method='put')) |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
220 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
221 def test_delete_hg(self): |
628 | 222 self.log_user() |
223 repo_name = 'vcs_test_new_to_delete' | |
224 description = 'description for newly created repo' | |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
225 response = self.app.post(url('repos'), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
226 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
227 repo_type='hg', |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
228 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
229 repo_description=description)) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
230 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
231 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
232 'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
233 % (repo_name, repo_name)) |
628 | 234 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
235 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
236 .filter(Repository.repo_name == repo_name).one() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
237 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
238 self.assertEqual(new_repo.repo_name, repo_name) |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
239 self.assertEqual(new_repo.description, description) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
240 |
628 | 241 #test if repository is visible in the list ? |
242 response = response.follow() | |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
243 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
244 response.mustcontain(repo_name) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
245 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
246 #test if repository was created on filesystem |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
247 try: |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
248 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
249 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
250 self.fail('no repo %s in filesystem' % repo_name) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
251 |
628 | 252 response = self.app.delete(url('repo', repo_name=repo_name)) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
253 |
3640
4f80df0d45c8
unified flash msg tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
254 self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name)) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
255 |
628 | 256 response.follow() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
257 |
628 | 258 #check if repo was deleted from db |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
259 deleted_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
260 .filter(Repository.repo_name == repo_name).scalar() |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
261 |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
262 self.assertEqual(deleted_repo, None) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
263 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
264 self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)), |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
265 False) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
266 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
267 def test_delete_git(self): |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
268 self.log_user() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
269 repo_name = 'vcs_test_new_to_delete' |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
270 description = 'description for newly created repo' |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
271 private = False |
3057
79c5967a1e5c
whitespace and formatting
Marcin Kuzminski <marcin@python-works.com>
parents:
3056
diff
changeset
|
272 response = self.app.post(url('repos'), |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
273 _get_repo_create_params(repo_private=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
274 repo_type='git', |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
275 repo_name=repo_name, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
276 repo_description=description)) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2529
diff
changeset
|
277 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
278 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3550
diff
changeset
|
279 'Created repository <a href="/%s">%s</a>' |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3222
diff
changeset
|
280 % (repo_name, repo_name)) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
281 #test if the repo was created in the database |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
282 new_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
283 .filter(Repository.repo_name == repo_name).one() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
284 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
285 self.assertEqual(new_repo.repo_name, repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
286 self.assertEqual(new_repo.description, description) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
287 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
288 #test if repository is visible in the list ? |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
289 response = response.follow() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
290 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
291 response.mustcontain(repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
292 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
293 #test if repository was created on filesystem |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
294 try: |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
295 vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name)) |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3629
diff
changeset
|
296 except Exception: |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
297 self.fail('no repo %s in filesystem' % repo_name) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
298 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
299 response = self.app.delete(url('repo', repo_name=repo_name)) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
300 |
3640
4f80df0d45c8
unified flash msg tests
Marcin Kuzminski <marcin@python-works.com>
parents:
3631
diff
changeset
|
301 self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name)) |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
302 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
303 response.follow() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
304 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
305 #check if repo was deleted from db |
2529
40b3a54391f9
Added functional test create repo with a group
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
306 deleted_repo = self.Session().query(Repository)\ |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
307 .filter(Repository.repo_name == repo_name).scalar() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
308 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
309 self.assertEqual(deleted_repo, None) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
310 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
311 self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)), |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
312 False) |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
313 |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
314 def test_delete_repo_with_group(self): |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
315 #TODO: |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
316 pass |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
317 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
318 def test_delete_browser_fakeout(self): |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
319 response = self.app.post(url('repo', repo_name=HG_REPO), |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1037
diff
changeset
|
320 params=dict(_method='delete')) |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
321 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
322 def test_show_hg(self): |
567
80dc0a23edf7
fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
323 self.log_user() |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
324 response = self.app.get(url('repo', repo_name=HG_REPO)) |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
325 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
326 def test_show_git(self): |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
327 self.log_user() |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
328 response = self.app.get(url('repo', repo_name=GIT_REPO)) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
329 |
47
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
330 |
f6ac79182600
Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff
changeset
|
331 def test_edit(self): |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
332 response = self.app.get(url('edit_repo', repo_name=HG_REPO)) |
3629
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
333 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
334 def test_set_private_flag_sets_default_to_none(self): |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
335 self.log_user() |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
336 #initially repository perm should be read |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
337 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
338 self.assertTrue(len(perm), 1) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
339 self.assertEqual(perm[0].permission.permission_name, 'repository.read') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
340 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
341 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
342 response = self.app.put(url('repo', repo_name=HG_REPO), |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
343 _get_repo_create_params(repo_private=1, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
344 repo_name=HG_REPO, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
345 user=TEST_USER_ADMIN_LOGIN)) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
346 self.checkSessionFlash(response, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
347 msg='Repository %s updated successfully' % (HG_REPO)) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
348 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, True) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
349 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
350 #now the repo default permission should be None |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
351 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
352 self.assertTrue(len(perm), 1) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
353 self.assertEqual(perm[0].permission.permission_name, 'repository.none') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
354 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
355 response = self.app.put(url('repo', repo_name=HG_REPO), |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
356 _get_repo_create_params(repo_private=False, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
357 repo_name=HG_REPO, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
358 user=TEST_USER_ADMIN_LOGIN)) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
359 self.checkSessionFlash(response, |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
360 msg='Repository %s updated successfully' % (HG_REPO)) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
361 self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
362 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
363 #we turn off private now the repo default permission should stay None |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
364 perm = _get_permission_for_user(user='default', repo=HG_REPO) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
365 self.assertTrue(len(perm), 1) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
366 self.assertEqual(perm[0].permission.permission_name, 'repository.none') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
367 |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
368 #update this permission back |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
369 perm[0].permission = Permission.get_by_key('repository.read') |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
370 Session().add(perm[0]) |
802c94bdfc85
#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
371 Session().commit() |