annotate rhodecode/tests/functional/test_home.py @ 2946:dbb311201ce3 beta

add test for enabling lightweight dashboard
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 20 Oct 2012 16:50:00 +0200
parents a2eaa0054430
children 9937afa7f093
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
6
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
7
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
8 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
9
298546182b41 more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 def test_index(self):
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
11 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
12 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
13 #if global permission is set
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
14 response.mustcontain('ADD REPOSITORY')
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
15 response.mustcontain('href="/%s/summary"' % HG_REPO)
875
0765fd5bf668 tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
16
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
17 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
18 """alt="Mercurial repository" src="/images/icons/hg"""
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
19 """icon.png"/>""")
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
20 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
21 """alt="public repository" src="/images/icons/lock_"""
1788
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
22 """open.png"/>""")
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
23
ef0613584ced test fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1481
diff changeset
24 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
25 """<a title="Marcin Kuzminski &amp;lt;marcin@python-works.com&amp;gt;:\n
f467c75544af Added h.tooltip to all places that tooltip_title is used.
Marcin Kuzminski <marcin@python-works.com>
parents: 1788
diff changeset
26 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
27 """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
28 )
2714
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
29
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
30 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
31 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
32 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
33 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
34 Session().commit()
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
35 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
36 try:
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
37 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
38 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
39 status=302)
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
40 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
41
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
42 finally:
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
43 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
44 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
45 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
46 Session().commit()
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
47
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
48 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
49 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
50 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
51 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
52 Session().commit()
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
53 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
54 try:
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
55 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
56 status=302)
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
57 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
58 finally:
a2eaa0054430 fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents: 2427
diff changeset
59 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
60 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
61 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
62 Session().commit()
2946
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
63
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
64 def test_index_with_lightweight_dashboard(self):
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
65 self.log_user()
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
66
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
67 def set_l_dash(set_to):
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
68 self.app.post(url('admin_setting', setting_id='visual'),
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
69 params=dict(_method='put',
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
70 rhodecode_lightweight_dashboard=set_to,))
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
71
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
72 set_l_dash(True)
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
73
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
74 try:
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
75 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
76 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
77 finally:
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
78 set_l_dash(False)
dbb311201ce3 add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents: 2714
diff changeset
79