Mercurial > kallithea
annotate rhodecode/tests/functional/test_home.py @ 3797:d7488551578e beta
synced vcs with upstream
- moved subprocessio module to VCS
- many small changes to make embedded vcs as similar to to external lib
- use only absolute imports
- patch vcs config during load pylons env
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 27 Apr 2013 11:24:25 +0200 |
parents | 1e5bb8ed77d6 |
children | f81b1fded4c9 |
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') |
3752
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
20 # html in javascript variable: |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
21 response.mustcontain("""var data = {"totalRecords": %s""" |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
22 % len(Repository.getAll())) |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
23 response.mustcontain(r'href=\"/%s\"' % HG_REPO) |
875 | 24 |
3752
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
25 response.mustcontain(r"""<img class=\"icon\" title=\"Mercurial repository\" """ |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
26 r"""alt=\"Mercurial repository\" src=\"/images/icons/hg""" |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
27 r"""icon.png\"/>""") |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
28 response.mustcontain(r"""<img class=\"icon\" title=\"Public repository\" """ |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
29 r"""alt=\"Public repository\" src=\"/images/icons/lock_""" |
1e5bb8ed77d6
index: always use lightweight - there shouldn't be any reason not to
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
30 r"""open.png\"/>""") |
1788 | 31 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
32 response.mustcontain("""fixes issue with having custom format for git-log""") |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
33 response.mustcontain("""/%s/changeset/5f2c6ee195929b0be80749243c18121c9864a3b3""" % GIT_REPO) |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
34 |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
35 response.mustcontain("""disable security checks on hg clone for travis""") |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3752
diff
changeset
|
36 response.mustcontain("""/%s/changeset/96507bd11ecc815ebc6270fdf6db110928c09c1e""" % HG_REPO) |
2714
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
37 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
43 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
|
44 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
45 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
|
46 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
|
47 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
48 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
|
49 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
50 finally: |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
55 |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 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
|
60 Session().commit() |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
61 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
|
62 try: |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
63 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
|
64 status=302) |
a2eaa0054430
fixed error when disabled anonymous access lead to error on server
Marcin Kuzminski <marcin@python-works.com>
parents:
2427
diff
changeset
|
65 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
|
66 finally: |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3654
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 Session().commit() |
2946
dbb311201ce3
add test for enabling lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
2714
diff
changeset
|
71 |
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
|
72 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
|
73 self.log_user() |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
74 gr = fixture.create_group('gr1') |
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
75 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
|
76 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
|
77 |
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
|
78 try: |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3291
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 Session().commit() |