Mercurial > kallithea
annotate rhodecode/tests/functional/test_home.py @ 3734:a8f520540ab0 beta
New default permissions definition for user group create
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 10 Apr 2013 14:33:04 +0200 |
parents | ec6354949623 |
children | 1e5bb8ed77d6 |
rev | line source |
---|---|
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
1 import time |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
464
diff
changeset
|
2 from rhodecode.tests import * |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
3 from rhodecode.tests.fixture import Fixture |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
4 from rhodecode.model.meta import Session |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
5 from rhodecode.model.db import User, Repository |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
6 from rhodecode.model.repo import RepoModel |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
7 from rhodecode.model.repos_group import ReposGroupModel |
462
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
1788 | 9 |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
10 fixture = Fixture() |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
11 |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
12 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
13 class TestHomeController(TestController): |
462
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 def test_index(self): |
464
cbe777be5b8c
some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
16 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:
547
diff
changeset
|
17 response = self.app.get(url(controller='home', action='index')) |
464
cbe777be5b8c
some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
18 #if global permission is set |
3215 | 19 response.mustcontain('Add repository') |
3291 | 20 response.mustcontain('href="/%s"' % HG_REPO) |
875 | 21 |
1788 | 22 response.mustcontain("""<img class="icon" title="Mercurial repository" """ |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
904
diff
changeset
|
23 """alt="Mercurial repository" src="/images/icons/hg""" |
1788 | 24 """icon.png"/>""") |
3654
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3647
diff
changeset
|
25 response.mustcontain("""<img class="icon" title="Public repository" """ |
ec6354949623
Fix a lot of casings - use standard casing in most places
Mads Kiilerich <madski@unity3d.com>
parents:
3647
diff
changeset
|
26 """alt="Public repository" src="/images/icons/lock_""" |
1788 | 27 """open.png"/>""") |
28 | |
29 response.mustcontain( | |
2427
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
1788
diff
changeset
|
30 """<a title="Marcin Kuzminski &lt;marcin@python-works.com&gt;:\n |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
1788
diff
changeset
|
31 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232""" |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
1788
diff
changeset
|
32 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>""" |
f467c75544af
Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents:
1788
diff
changeset
|
33 ) |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
34 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
35 def test_repo_summary_with_anonymous_access_disabled(self): |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
36 anon = User.get_default_user() |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
37 anon.active = False |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
38 Session().add(anon) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
39 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
40 time.sleep(1.5) # must sleep for cache (1s to expire) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
41 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
42 response = self.app.get(url(controller='summary', |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
43 action='index', repo_name=HG_REPO), |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
44 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
45 assert 'login' in response.location |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
46 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
47 finally: |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
48 anon = User.get_default_user() |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
49 anon.active = True |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
50 Session().add(anon) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
51 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
52 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
53 def test_index_with_anonymous_access_disabled(self): |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
54 anon = User.get_default_user() |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
55 anon.active = False |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
56 Session().add(anon) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
57 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
58 time.sleep(1.5) # must sleep for cache (1s to expire) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
59 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
60 response = self.app.get(url(controller='home', action='index'), |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
61 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
62 assert 'login' in response.location |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
63 finally: |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
64 anon = User.get_default_user() |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
65 anon.active = True |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
66 Session().add(anon) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
67 Session().commit() |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
68 |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
69 def _set_l_dash(self, set_to): |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
70 self.app.post(url('admin_setting', setting_id='visual'), |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
71 params=dict(_method='put', |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
72 rhodecode_lightweight_dashboard=set_to,)) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
73 |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
74 def test_index_with_lightweight_dashboard(self): |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
75 self.log_user() |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
76 self._set_l_dash(True) |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
77 |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
78 try: |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
79 response = self.app.get(url(controller='home', action='index')) |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
80 response.mustcontain("""var data = {"totalRecords": %s""" |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
81 % len(Repository.getAll())) |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
82 finally: |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
83 self._set_l_dash(False) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
84 |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
85 def test_index_page_on_groups(self): |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
86 self.log_user() |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
87 gr = fixture.create_group('gr1') |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
88 fixture.create_repo(name='gr1/repo_in_group', repos_group=gr) |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
89 response = self.app.get(url('repos_group_home', group_name='gr1')) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
90 |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
91 try: |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
92 response.mustcontain("gr1/repo_in_group") |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
93 finally: |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
94 RepoModel().delete('gr1/repo_in_group') |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
95 ReposGroupModel().delete(repos_group='gr1', force_delete=True) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
96 Session().commit() |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
97 |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
98 def test_index_page_on_groups_with_lightweight_dashboard(self): |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
99 self.log_user() |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
100 self._set_l_dash(True) |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
101 fixture.create_repo(name='gr1/repo_in_group', |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
102 repos_group=fixture.create_group('gr1')) |
3167
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
103 response = self.app.get(url('repos_group_home', group_name='gr1')) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
104 |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
105 try: |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
106 response.mustcontain("""gr1/repo_in_group""") |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
107 finally: |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
108 self._set_l_dash(False) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
109 RepoModel().delete('gr1/repo_in_group') |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
110 ReposGroupModel().delete(repos_group='gr1', force_delete=True) |
87258a137018
fixed issue with displaying repos in groups view (without lightweight dashboard), added tests for this case
Marcin Kuzminski <marcin@python-works.com>
parents:
2973
diff
changeset
|
111 Session().commit() |