Mercurial > kallithea
annotate rhodecode/tests/functional/test_home.py @ 3291:f4ce9416cbd5 beta
fixed tests
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 31 Jan 2013 23:23:56 +0100 |
parents | cbc63abe7d59 |
children | 8a86836fad64 |
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 * |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
3 from rhodecode.model.meta import Session |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
5 from rhodecode.lib.utils import set_rhodecode_config |
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.tests.models.common import _make_repo, _make_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
|
7 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
|
8 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
|
9 |
1788 | 10 |
691
7486da5f0628
Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents:
688
diff
changeset
|
11 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
|
12 |
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 def test_index(self): |
464
cbe777be5b8c
some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
14 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
|
15 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
|
16 #if global permission is set |
3215 | 17 response.mustcontain('Add repository') |
3291 | 18 response.mustcontain('href="/%s"' % HG_REPO) |
875 | 19 |
1788 | 20 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
|
21 """alt="Mercurial repository" src="/images/icons/hg""" |
1788 | 22 """icon.png"/>""") |
23 response.mustcontain("""<img class="icon" title="public repository" """ | |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
904
diff
changeset
|
24 """alt="public repository" src="/images/icons/lock_""" |
1788 | 25 """open.png"/>""") |
26 | |
27 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
|
28 """<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
|
29 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
|
30 """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
|
31 ) |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
32 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
33 def test_repo_summary_with_anonymous_access_disabled(self): |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
34 anon = User.get_by_username('default') |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
35 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
|
36 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
|
37 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
38 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
|
39 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
40 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
|
41 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
|
42 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
43 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
|
44 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
45 finally: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
46 anon = User.get_by_username('default') |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
47 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
|
48 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
|
49 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
50 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
51 def test_index_with_anonymous_access_disabled(self): |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
52 anon = User.get_by_username('default') |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
53 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
|
54 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
|
55 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
56 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
|
57 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
58 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
|
59 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
60 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
|
61 finally: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
62 anon = User.get_by_username('default') |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
63 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
|
64 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
|
65 Session().commit() |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
66 |
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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
72 def test_index_with_lightweight_dashboard(self): |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
73 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
|
74 self._set_l_dash(True) |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
75 |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
76 try: |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
77 response = self.app.get(url(controller='home', action='index')) |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
78 response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll())) |
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
79 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
|
80 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
|
81 |
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
|
82 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
|
83 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
|
84 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('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
|
85 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
|
86 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
|
87 |
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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 |
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 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
|
96 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
|
97 self._set_l_dash(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
|
98 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('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
|
99 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
|
100 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
|
101 |
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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 Session().commit() |