##// END OF EJS Templates
fixed tests
marcink -
r3291:f4ce9416 beta
parent child Browse files
Show More
@@ -1,175 +1,175 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2
2
3 from rhodecode.model.db import Repository
3 from rhodecode.model.db import Repository
4 from rhodecode.model.repo import RepoModel
4 from rhodecode.model.repo import RepoModel
5 from rhodecode.model.user import UserModel
5 from rhodecode.model.user import UserModel
6 from rhodecode.model.meta import Session
6 from rhodecode.model.meta import Session
7
7
8
8
9 class TestForksController(TestController):
9 class TestForksController(TestController):
10
10
11 def setUp(self):
11 def setUp(self):
12 self.username = u'forkuser'
12 self.username = u'forkuser'
13 self.password = u'qweqwe'
13 self.password = u'qweqwe'
14 self.u1 = UserModel().create_or_update(
14 self.u1 = UserModel().create_or_update(
15 username=self.username, password=self.password,
15 username=self.username, password=self.password,
16 email=u'fork_king@rhodecode.org', firstname=u'u1', lastname=u'u1'
16 email=u'fork_king@rhodecode.org', firstname=u'u1', lastname=u'u1'
17 )
17 )
18 Session().commit()
18 Session().commit()
19
19
20 def tearDown(self):
20 def tearDown(self):
21 Session().delete(self.u1)
21 Session().delete(self.u1)
22 Session().commit()
22 Session().commit()
23
23
24 def test_index(self):
24 def test_index(self):
25 self.log_user()
25 self.log_user()
26 repo_name = HG_REPO
26 repo_name = HG_REPO
27 response = self.app.get(url(controller='forks', action='forks',
27 response = self.app.get(url(controller='forks', action='forks',
28 repo_name=repo_name))
28 repo_name=repo_name))
29
29
30 self.assertTrue("""There are no forks yet""" in response.body)
30 self.assertTrue("""There are no forks yet""" in response.body)
31
31
32 def test_no_permissions_to_fork(self):
32 def test_no_permissions_to_fork(self):
33 usr = self.log_user(TEST_USER_REGULAR_LOGIN,
33 usr = self.log_user(TEST_USER_REGULAR_LOGIN,
34 TEST_USER_REGULAR_PASS)['user_id']
34 TEST_USER_REGULAR_PASS)['user_id']
35 user_model = UserModel()
35 user_model = UserModel()
36 user_model.revoke_perm(usr, 'hg.fork.repository')
36 user_model.revoke_perm(usr, 'hg.fork.repository')
37 user_model.grant_perm(usr, 'hg.fork.none')
37 user_model.grant_perm(usr, 'hg.fork.none')
38 u = UserModel().get(usr)
38 u = UserModel().get(usr)
39 u.inherit_default_permissions = False
39 u.inherit_default_permissions = False
40 Session().commit()
40 Session().commit()
41 # try create a fork
41 # try create a fork
42 repo_name = HG_REPO
42 repo_name = HG_REPO
43 self.app.post(url(controller='forks', action='fork_create',
43 self.app.post(url(controller='forks', action='fork_create',
44 repo_name=repo_name), {}, status=403)
44 repo_name=repo_name), {}, status=403)
45
45
46 def test_index_with_fork_hg(self):
46 def test_index_with_fork_hg(self):
47 self.log_user()
47 self.log_user()
48
48
49 # create a fork
49 # create a fork
50 fork_name = HG_FORK
50 fork_name = HG_FORK
51 description = 'fork of vcs test'
51 description = 'fork of vcs test'
52 repo_name = HG_REPO
52 repo_name = HG_REPO
53 org_repo = Repository.get_by_repo_name(repo_name)
53 org_repo = Repository.get_by_repo_name(repo_name)
54 response = self.app.post(url(controller='forks',
54 response = self.app.post(url(controller='forks',
55 action='fork_create',
55 action='fork_create',
56 repo_name=repo_name),
56 repo_name=repo_name),
57 {'repo_name': fork_name,
57 {'repo_name': fork_name,
58 'repo_group': '',
58 'repo_group': '',
59 'fork_parent_id': org_repo.repo_id,
59 'fork_parent_id': org_repo.repo_id,
60 'repo_type': 'hg',
60 'repo_type': 'hg',
61 'description': description,
61 'description': description,
62 'private': 'False',
62 'private': 'False',
63 'landing_rev': 'tip'})
63 'landing_rev': 'tip'})
64
64
65 response = self.app.get(url(controller='forks', action='forks',
65 response = self.app.get(url(controller='forks', action='forks',
66 repo_name=repo_name))
66 repo_name=repo_name))
67
67
68 response.mustcontain(
68 response.mustcontain(
69 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name)
69 """<a href="/%s">%s</a>""" % (fork_name, fork_name)
70 )
70 )
71
71
72 #remove this fork
72 #remove this fork
73 response = self.app.delete(url('repo', repo_name=fork_name))
73 response = self.app.delete(url('repo', repo_name=fork_name))
74
74
75 def test_index_with_fork_git(self):
75 def test_index_with_fork_git(self):
76 self.log_user()
76 self.log_user()
77
77
78 # create a fork
78 # create a fork
79 fork_name = GIT_FORK
79 fork_name = GIT_FORK
80 description = 'fork of vcs test'
80 description = 'fork of vcs test'
81 repo_name = GIT_REPO
81 repo_name = GIT_REPO
82 org_repo = Repository.get_by_repo_name(repo_name)
82 org_repo = Repository.get_by_repo_name(repo_name)
83 response = self.app.post(url(controller='forks',
83 response = self.app.post(url(controller='forks',
84 action='fork_create',
84 action='fork_create',
85 repo_name=repo_name),
85 repo_name=repo_name),
86 {'repo_name': fork_name,
86 {'repo_name': fork_name,
87 'repo_group': '',
87 'repo_group': '',
88 'fork_parent_id': org_repo.repo_id,
88 'fork_parent_id': org_repo.repo_id,
89 'repo_type': 'git',
89 'repo_type': 'git',
90 'description': description,
90 'description': description,
91 'private': 'False',
91 'private': 'False',
92 'landing_rev': 'tip'})
92 'landing_rev': 'tip'})
93
93
94 response = self.app.get(url(controller='forks', action='forks',
94 response = self.app.get(url(controller='forks', action='forks',
95 repo_name=repo_name))
95 repo_name=repo_name))
96
96
97 response.mustcontain(
97 response.mustcontain(
98 """<a href="/%s/summary">%s</a>""" % (fork_name, fork_name)
98 """<a href="/%s">%s</a>""" % (fork_name, fork_name)
99 )
99 )
100
100
101 #remove this fork
101 #remove this fork
102 response = self.app.delete(url('repo', repo_name=fork_name))
102 response = self.app.delete(url('repo', repo_name=fork_name))
103
103
104 def test_z_fork_create(self):
104 def test_z_fork_create(self):
105 self.log_user()
105 self.log_user()
106 fork_name = HG_FORK
106 fork_name = HG_FORK
107 description = 'fork of vcs test'
107 description = 'fork of vcs test'
108 repo_name = HG_REPO
108 repo_name = HG_REPO
109 org_repo = Repository.get_by_repo_name(repo_name)
109 org_repo = Repository.get_by_repo_name(repo_name)
110 response = self.app.post(url(controller='forks', action='fork_create',
110 response = self.app.post(url(controller='forks', action='fork_create',
111 repo_name=repo_name),
111 repo_name=repo_name),
112 {'repo_name':fork_name,
112 {'repo_name':fork_name,
113 'repo_group':'',
113 'repo_group':'',
114 'fork_parent_id':org_repo.repo_id,
114 'fork_parent_id':org_repo.repo_id,
115 'repo_type':'hg',
115 'repo_type':'hg',
116 'description':description,
116 'description':description,
117 'private':'False',
117 'private':'False',
118 'landing_rev': 'tip'})
118 'landing_rev': 'tip'})
119
119
120 #test if we have a message that fork is ok
120 #test if we have a message that fork is ok
121 self.checkSessionFlash(response,
121 self.checkSessionFlash(response,
122 'forked %s repository as %s' % (repo_name, fork_name))
122 'forked %s repository as %s' % (repo_name, fork_name))
123
123
124 #test if the fork was created in the database
124 #test if the fork was created in the database
125 fork_repo = Session().query(Repository)\
125 fork_repo = Session().query(Repository)\
126 .filter(Repository.repo_name == fork_name).one()
126 .filter(Repository.repo_name == fork_name).one()
127
127
128 self.assertEqual(fork_repo.repo_name, fork_name)
128 self.assertEqual(fork_repo.repo_name, fork_name)
129 self.assertEqual(fork_repo.fork.repo_name, repo_name)
129 self.assertEqual(fork_repo.fork.repo_name, repo_name)
130
130
131 #test if fork is visible in the list ?
131 #test if fork is visible in the list ?
132 response = response.follow()
132 response = response.follow()
133
133
134 response = self.app.get(url(controller='summary', action='index',
134 response = self.app.get(url(controller='summary', action='index',
135 repo_name=fork_name))
135 repo_name=fork_name))
136
136
137 self.assertTrue('Fork of %s' % repo_name in response.body)
137 self.assertTrue('Fork of %s' % repo_name in response.body)
138
138
139 def test_zz_fork_permission_page(self):
139 def test_zz_fork_permission_page(self):
140 usr = self.log_user(self.username, self.password)['user_id']
140 usr = self.log_user(self.username, self.password)['user_id']
141 repo_name = HG_REPO
141 repo_name = HG_REPO
142
142
143 forks = Session().query(Repository)\
143 forks = Session().query(Repository)\
144 .filter(Repository.fork_id != None)\
144 .filter(Repository.fork_id != None)\
145 .all()
145 .all()
146 self.assertEqual(1, len(forks))
146 self.assertEqual(1, len(forks))
147
147
148 # set read permissions for this
148 # set read permissions for this
149 RepoModel().grant_user_permission(repo=forks[0],
149 RepoModel().grant_user_permission(repo=forks[0],
150 user=usr,
150 user=usr,
151 perm='repository.read')
151 perm='repository.read')
152 Session().commit()
152 Session().commit()
153
153
154 response = self.app.get(url(controller='forks', action='forks',
154 response = self.app.get(url(controller='forks', action='forks',
155 repo_name=repo_name))
155 repo_name=repo_name))
156
156
157 response.mustcontain('<div style="padding:5px 3px 3px 42px;">fork of vcs test</div>')
157 response.mustcontain('<div style="padding:5px 3px 3px 42px;">fork of vcs test</div>')
158
158
159 def test_zzz_fork_permission_page(self):
159 def test_zzz_fork_permission_page(self):
160 usr = self.log_user(self.username, self.password)['user_id']
160 usr = self.log_user(self.username, self.password)['user_id']
161 repo_name = HG_REPO
161 repo_name = HG_REPO
162
162
163 forks = Session().query(Repository)\
163 forks = Session().query(Repository)\
164 .filter(Repository.fork_id != None)\
164 .filter(Repository.fork_id != None)\
165 .all()
165 .all()
166 self.assertEqual(1, len(forks))
166 self.assertEqual(1, len(forks))
167
167
168 # set none
168 # set none
169 RepoModel().grant_user_permission(repo=forks[0],
169 RepoModel().grant_user_permission(repo=forks[0],
170 user=usr, perm='repository.none')
170 user=usr, perm='repository.none')
171 Session().commit()
171 Session().commit()
172 # fork shouldn't be there
172 # fork shouldn't be there
173 response = self.app.get(url(controller='forks', action='forks',
173 response = self.app.get(url(controller='forks', action='forks',
174 repo_name=repo_name))
174 repo_name=repo_name))
175 response.mustcontain('There are no forks yet')
175 response.mustcontain('There are no forks yet')
@@ -1,108 +1,108 b''
1 import time
1 import time
2 from rhodecode.tests import *
2 from rhodecode.tests import *
3 from rhodecode.model.meta import Session
3 from rhodecode.model.meta import Session
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository
4 from rhodecode.model.db import User, RhodeCodeSetting, Repository
5 from rhodecode.lib.utils import set_rhodecode_config
5 from rhodecode.lib.utils import set_rhodecode_config
6 from rhodecode.tests.models.common import _make_repo, _make_group
6 from rhodecode.tests.models.common import _make_repo, _make_group
7 from rhodecode.model.repo import RepoModel
7 from rhodecode.model.repo import RepoModel
8 from rhodecode.model.repos_group import ReposGroupModel
8 from rhodecode.model.repos_group import ReposGroupModel
9
9
10
10
11 class TestHomeController(TestController):
11 class TestHomeController(TestController):
12
12
13 def test_index(self):
13 def test_index(self):
14 self.log_user()
14 self.log_user()
15 response = self.app.get(url(controller='home', action='index'))
15 response = self.app.get(url(controller='home', action='index'))
16 #if global permission is set
16 #if global permission is set
17 response.mustcontain('Add repository')
17 response.mustcontain('Add repository')
18 response.mustcontain('href="/%s/summary"' % HG_REPO)
18 response.mustcontain('href="/%s"' % HG_REPO)
19
19
20 response.mustcontain("""<img class="icon" title="Mercurial repository" """
20 response.mustcontain("""<img class="icon" title="Mercurial repository" """
21 """alt="Mercurial repository" src="/images/icons/hg"""
21 """alt="Mercurial repository" src="/images/icons/hg"""
22 """icon.png"/>""")
22 """icon.png"/>""")
23 response.mustcontain("""<img class="icon" title="public repository" """
23 response.mustcontain("""<img class="icon" title="public repository" """
24 """alt="public repository" src="/images/icons/lock_"""
24 """alt="public repository" src="/images/icons/lock_"""
25 """open.png"/>""")
25 """open.png"/>""")
26
26
27 response.mustcontain(
27 response.mustcontain(
28 """<a title="Marcin Kuzminski &amp;lt;marcin@python-works.com&amp;gt;:\n
28 """<a title="Marcin Kuzminski &amp;lt;marcin@python-works.com&amp;gt;:\n
29 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232"""
29 merge" class="tooltip" href="/vcs_test_hg/changeset/27cd5cce30c96924232"""
30 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>"""
30 """dffcd24178a07ffeb5dfc">r173:27cd5cce30c9</a>"""
31 )
31 )
32
32
33 def test_repo_summary_with_anonymous_access_disabled(self):
33 def test_repo_summary_with_anonymous_access_disabled(self):
34 anon = User.get_by_username('default')
34 anon = User.get_by_username('default')
35 anon.active = False
35 anon.active = False
36 Session().add(anon)
36 Session().add(anon)
37 Session().commit()
37 Session().commit()
38 time.sleep(1.5) # must sleep for cache (1s to expire)
38 time.sleep(1.5) # must sleep for cache (1s to expire)
39 try:
39 try:
40 response = self.app.get(url(controller='summary',
40 response = self.app.get(url(controller='summary',
41 action='index', repo_name=HG_REPO),
41 action='index', repo_name=HG_REPO),
42 status=302)
42 status=302)
43 assert 'login' in response.location
43 assert 'login' in response.location
44
44
45 finally:
45 finally:
46 anon = User.get_by_username('default')
46 anon = User.get_by_username('default')
47 anon.active = True
47 anon.active = True
48 Session().add(anon)
48 Session().add(anon)
49 Session().commit()
49 Session().commit()
50
50
51 def test_index_with_anonymous_access_disabled(self):
51 def test_index_with_anonymous_access_disabled(self):
52 anon = User.get_by_username('default')
52 anon = User.get_by_username('default')
53 anon.active = False
53 anon.active = False
54 Session().add(anon)
54 Session().add(anon)
55 Session().commit()
55 Session().commit()
56 time.sleep(1.5) # must sleep for cache (1s to expire)
56 time.sleep(1.5) # must sleep for cache (1s to expire)
57 try:
57 try:
58 response = self.app.get(url(controller='home', action='index'),
58 response = self.app.get(url(controller='home', action='index'),
59 status=302)
59 status=302)
60 assert 'login' in response.location
60 assert 'login' in response.location
61 finally:
61 finally:
62 anon = User.get_by_username('default')
62 anon = User.get_by_username('default')
63 anon.active = True
63 anon.active = True
64 Session().add(anon)
64 Session().add(anon)
65 Session().commit()
65 Session().commit()
66
66
67 def _set_l_dash(self, set_to):
67 def _set_l_dash(self, set_to):
68 self.app.post(url('admin_setting', setting_id='visual'),
68 self.app.post(url('admin_setting', setting_id='visual'),
69 params=dict(_method='put',
69 params=dict(_method='put',
70 rhodecode_lightweight_dashboard=set_to,))
70 rhodecode_lightweight_dashboard=set_to,))
71
71
72 def test_index_with_lightweight_dashboard(self):
72 def test_index_with_lightweight_dashboard(self):
73 self.log_user()
73 self.log_user()
74 self._set_l_dash(True)
74 self._set_l_dash(True)
75
75
76 try:
76 try:
77 response = self.app.get(url(controller='home', action='index'))
77 response = self.app.get(url(controller='home', action='index'))
78 response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll()))
78 response.mustcontain("""var data = {"totalRecords": %s""" % len(Repository.getAll()))
79 finally:
79 finally:
80 self._set_l_dash(False)
80 self._set_l_dash(False)
81
81
82 def test_index_page_on_groups(self):
82 def test_index_page_on_groups(self):
83 self.log_user()
83 self.log_user()
84 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('gr1'))
84 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('gr1'))
85 Session().commit()
85 Session().commit()
86 response = self.app.get(url('repos_group_home', group_name='gr1'))
86 response = self.app.get(url('repos_group_home', group_name='gr1'))
87
87
88 try:
88 try:
89 response.mustcontain("""gr1/repo_in_group""")
89 response.mustcontain("""gr1/repo_in_group""")
90 finally:
90 finally:
91 RepoModel().delete('gr1/repo_in_group')
91 RepoModel().delete('gr1/repo_in_group')
92 ReposGroupModel().delete(repos_group='gr1', force_delete=True)
92 ReposGroupModel().delete(repos_group='gr1', force_delete=True)
93 Session().commit()
93 Session().commit()
94
94
95 def test_index_page_on_groups_with_lightweight_dashboard(self):
95 def test_index_page_on_groups_with_lightweight_dashboard(self):
96 self.log_user()
96 self.log_user()
97 self._set_l_dash(True)
97 self._set_l_dash(True)
98 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('gr1'))
98 _make_repo(name='gr1/repo_in_group', repos_group=_make_group('gr1'))
99 Session().commit()
99 Session().commit()
100 response = self.app.get(url('repos_group_home', group_name='gr1'))
100 response = self.app.get(url('repos_group_home', group_name='gr1'))
101
101
102 try:
102 try:
103 response.mustcontain("""gr1/repo_in_group""")
103 response.mustcontain("""gr1/repo_in_group""")
104 finally:
104 finally:
105 self._set_l_dash(False)
105 self._set_l_dash(False)
106 RepoModel().delete('gr1/repo_in_group')
106 RepoModel().delete('gr1/repo_in_group')
107 ReposGroupModel().delete(repos_group='gr1', force_delete=True)
107 ReposGroupModel().delete(repos_group='gr1', force_delete=True)
108 Session().commit()
108 Session().commit()
@@ -1,114 +1,114 b''
1 import os
1 import os
2 from rhodecode.tests import *
2 from rhodecode.tests import *
3 from nose.plugins.skip import SkipTest
3 from nose.plugins.skip import SkipTest
4
4
5
5
6 class TestSearchController(TestController):
6 class TestSearchController(TestController):
7
7
8 def test_index(self):
8 def test_index(self):
9 self.log_user()
9 self.log_user()
10 response = self.app.get(url(controller='search', action='index'))
10 response = self.app.get(url(controller='search', action='index'))
11
11
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
13 response.body)
13 response.body)
14 # Test response...
14 # Test response...
15
15
16 def test_empty_search(self):
16 def test_empty_search(self):
17 if os.path.isdir(self.index_location):
17 if os.path.isdir(self.index_location):
18 raise SkipTest('skipped due to existing index')
18 raise SkipTest('skipped due to existing index')
19 else:
19 else:
20 self.log_user()
20 self.log_user()
21 response = self.app.get(url(controller='search', action='index'),
21 response = self.app.get(url(controller='search', action='index'),
22 {'q': HG_REPO})
22 {'q': HG_REPO})
23 self.assertTrue('There is no index to search in. '
23 self.assertTrue('There is no index to search in. '
24 'Please run whoosh indexer' in response.body)
24 'Please run whoosh indexer' in response.body)
25
25
26 def test_normal_search(self):
26 def test_normal_search(self):
27 self.log_user()
27 self.log_user()
28 response = self.app.get(url(controller='search', action='index'),
28 response = self.app.get(url(controller='search', action='index'),
29 {'q': 'def repo'})
29 {'q': 'def repo'})
30 response.mustcontain('39 results')
30 response.mustcontain('39 results')
31
31
32 def test_repo_search(self):
32 def test_repo_search(self):
33 self.log_user()
33 self.log_user()
34 response = self.app.get(url(controller='search', action='index'),
34 response = self.app.get(url(controller='search', action='index'),
35 {'q': 'repository:%s def test' % HG_REPO})
35 {'q': 'repository:%s def test' % HG_REPO})
36
36
37 response.mustcontain('4 results')
37 response.mustcontain('4 results')
38
38
39 def test_search_last(self):
39 def test_search_last(self):
40 self.log_user()
40 self.log_user()
41 response = self.app.get(url(controller='search', action='index'),
41 response = self.app.get(url(controller='search', action='index'),
42 {'q': 'last:t', 'type': 'commit'})
42 {'q': 'last:t', 'type': 'commit'})
43
43
44 response.mustcontain('2 results')
44 response.mustcontain('2 results')
45
45
46 def test_search_commit_message(self):
46 def test_search_commit_message(self):
47 self.log_user()
47 self.log_user()
48 response = self.app.get(url(controller='search', action='index'),
48 response = self.app.get(url(controller='search', action='index'),
49 {'q': 'bother to ask where to fetch repo during tests',
49 {'q': 'bother to ask where to fetch repo during tests',
50 'type': 'commit'})
50 'type': 'commit'})
51
51
52 response.mustcontain('2 results')
52 response.mustcontain('2 results')
53 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
53 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
54 response.mustcontain('c6eb379775c578a95dad8ddab53f963b80894850')
54 response.mustcontain('c6eb379775c578a95dad8ddab53f963b80894850')
55
55
56 def test_search_commit_message_hg_repo(self):
56 def test_search_commit_message_hg_repo(self):
57 self.log_user()
57 self.log_user()
58 response = self.app.get(url(controller='search', action='index',
58 response = self.app.get(url(controller='search', action='index',
59 search_repo=HG_REPO),
59 repo_name=HG_REPO),
60 {'q': 'bother to ask where to fetch repo during tests',
60 {'q': 'bother to ask where to fetch repo during tests',
61 'type': 'commit'})
61 'type': 'commit'})
62
62
63 response.mustcontain('1 results')
63 response.mustcontain('1 results')
64 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
64 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
65
65
66 def test_search_commit_changed_file(self):
66 def test_search_commit_changed_file(self):
67 self.log_user()
67 self.log_user()
68 response = self.app.get(url(controller='search', action='index'),
68 response = self.app.get(url(controller='search', action='index'),
69 {'q': 'changed:tests/utils.py',
69 {'q': 'changed:tests/utils.py',
70 'type': 'commit'})
70 'type': 'commit'})
71
71
72 response.mustcontain('20 results')
72 response.mustcontain('20 results')
73
73
74 def test_search_commit_changed_files_get_commit(self):
74 def test_search_commit_changed_files_get_commit(self):
75 self.log_user()
75 self.log_user()
76 response = self.app.get(url(controller='search', action='index'),
76 response = self.app.get(url(controller='search', action='index'),
77 {'q': 'changed:vcs/utils/lazy.py',
77 {'q': 'changed:vcs/utils/lazy.py',
78 'type': 'commit'})
78 'type': 'commit'})
79
79
80 response.mustcontain('7 results')
80 response.mustcontain('7 results')
81 response.mustcontain('36e0fc9d2808c5022a24f49d6658330383ed8666')
81 response.mustcontain('36e0fc9d2808c5022a24f49d6658330383ed8666')
82 response.mustcontain('af182745859d779f17336241a0815d15166ae1ee')
82 response.mustcontain('af182745859d779f17336241a0815d15166ae1ee')
83 response.mustcontain('17438a11f72b93f56d0e08e7d1fa79a378578a82')
83 response.mustcontain('17438a11f72b93f56d0e08e7d1fa79a378578a82')
84 response.mustcontain('33fa3223355104431402a888fa77a4e9956feb3e')
84 response.mustcontain('33fa3223355104431402a888fa77a4e9956feb3e')
85 response.mustcontain('d1f898326327e20524fe22417c22d71064fe54a1')
85 response.mustcontain('d1f898326327e20524fe22417c22d71064fe54a1')
86 response.mustcontain('fe568b4081755c12abf6ba673ba777fc02a415f3')
86 response.mustcontain('fe568b4081755c12abf6ba673ba777fc02a415f3')
87 response.mustcontain('bafe786f0d8c2ff7da5c1dcfcfa577de0b5e92f1')
87 response.mustcontain('bafe786f0d8c2ff7da5c1dcfcfa577de0b5e92f1')
88
88
89 def test_search_commit_added_file(self):
89 def test_search_commit_added_file(self):
90 self.log_user()
90 self.log_user()
91 response = self.app.get(url(controller='search', action='index'),
91 response = self.app.get(url(controller='search', action='index'),
92 {'q': 'added:README.rst',
92 {'q': 'added:README.rst',
93 'type': 'commit'})
93 'type': 'commit'})
94
94
95 response.mustcontain('2 results')
95 response.mustcontain('2 results')
96 #HG
96 #HG
97 response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
97 response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
98 #GIT
98 #GIT
99 response.mustcontain('ff7ca51e58c505fec0dd2491de52c622bb7a806b')
99 response.mustcontain('ff7ca51e58c505fec0dd2491de52c622bb7a806b')
100
100
101 def test_search_author(self):
101 def test_search_author(self):
102 self.log_user()
102 self.log_user()
103 response = self.app.get(url(controller='search', action='index'),
103 response = self.app.get(url(controller='search', action='index'),
104 {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545',
104 {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545',
105 'type': 'commit'})
105 'type': 'commit'})
106
106
107 response.mustcontain('1 results')
107 response.mustcontain('1 results')
108
108
109 def test_search_file_name(self):
109 def test_search_file_name(self):
110 self.log_user()
110 self.log_user()
111 response = self.app.get(url(controller='search', action='index'),
111 response = self.app.get(url(controller='search', action='index'),
112 {'q': 'README.rst', 'type': 'path'})
112 {'q': 'README.rst', 'type': 'path'})
113
113
114 response.mustcontain('2 results')
114 response.mustcontain('2 results')
@@ -1,121 +1,121 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2 from rhodecode.model.db import Repository
2 from rhodecode.model.db import Repository
3 from rhodecode.lib.utils import invalidate_cache
3 from rhodecode.lib.utils import invalidate_cache
4 from rhodecode.model.repo import RepoModel
4 from rhodecode.model.repo import RepoModel
5 from rhodecode.tests.models.common import _make_repo
5 from rhodecode.tests.models.common import _make_repo
6 from rhodecode.model.meta import Session
6 from rhodecode.model.meta import Session
7
7
8
8
9 class TestSummaryController(TestController):
9 class TestSummaryController(TestController):
10
10
11 def test_index(self):
11 def test_index(self):
12 self.log_user()
12 self.log_user()
13 ID = Repository.get_by_repo_name(HG_REPO).repo_id
13 ID = Repository.get_by_repo_name(HG_REPO).repo_id
14 response = self.app.get(url(controller='summary',
14 response = self.app.get(url(controller='summary',
15 action='index',
15 action='index',
16 repo_name=HG_REPO))
16 repo_name=HG_REPO))
17
17
18 #repo type
18 #repo type
19 response.mustcontain(
19 response.mustcontain(
20 """<img style="margin-bottom:2px" class="icon" """
20 """<img style="margin-bottom:2px" class="icon" """
21 """title="Mercurial repository" alt="Mercurial repository" """
21 """title="Mercurial repository" alt="Mercurial repository" """
22 """src="/images/icons/hgicon.png"/>"""
22 """src="/images/icons/hgicon.png"/>"""
23 )
23 )
24 response.mustcontain(
24 response.mustcontain(
25 """<img style="margin-bottom:2px" class="icon" """
25 """<img style="margin-bottom:2px" class="icon" """
26 """title="public repository" alt="public """
26 """title="public repository" alt="public """
27 """repository" src="/images/icons/lock_open.png"/>"""
27 """repository" src="/images/icons/lock_open.png"/>"""
28 )
28 )
29
29
30 #codes stats
30 #codes stats
31 self._enable_stats()
31 self._enable_stats()
32
32
33 invalidate_cache('get_repo_cached_%s' % HG_REPO)
33 invalidate_cache('get_repo_cached_%s' % HG_REPO)
34 response = self.app.get(url(controller='summary', action='index',
34 response = self.app.get(url(controller='summary', action='index',
35 repo_name=HG_REPO))
35 repo_name=HG_REPO))
36 response.mustcontain(
36 response.mustcontain(
37 """var data = [["py", {"count": 42, "desc": ["Python"]}], """
37 """var data = [["py", {"count": 42, "desc": ["Python"]}], """
38 """["rst", {"count": 11, "desc": ["Rst"]}], """
38 """["rst", {"count": 11, "desc": ["Rst"]}], """
39 """["sh", {"count": 2, "desc": ["Bash"]}], """
39 """["sh", {"count": 2, "desc": ["Bash"]}], """
40 """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}],"""
40 """["makefile", {"count": 1, "desc": ["Makefile", "Makefile"]}],"""
41 """ ["cfg", {"count": 1, "desc": ["Ini"]}], """
41 """ ["cfg", {"count": 1, "desc": ["Ini"]}], """
42 """["css", {"count": 1, "desc": ["Css"]}], """
42 """["css", {"count": 1, "desc": ["Css"]}], """
43 """["bat", {"count": 1, "desc": ["Batch"]}]];"""
43 """["bat", {"count": 1, "desc": ["Batch"]}]];"""
44 )
44 )
45
45
46 # clone url...
46 # clone url...
47 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % HG_REPO)
47 response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % HG_REPO)
48 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
48 response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID)
49
49
50 def test_index_git(self):
50 def test_index_git(self):
51 self.log_user()
51 self.log_user()
52 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
52 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
53 response = self.app.get(url(controller='summary',
53 response = self.app.get(url(controller='summary',
54 action='index',
54 action='index',
55 repo_name=GIT_REPO))
55 repo_name=GIT_REPO))
56
56
57 #repo type
57 #repo type
58 response.mustcontain(
58 response.mustcontain(
59 """<img style="margin-bottom:2px" class="icon" """
59 """<img style="margin-bottom:2px" class="icon" """
60 """title="Git repository" alt="Git repository" """
60 """title="Git repository" alt="Git repository" """
61 """src="/images/icons/giticon.png"/>"""
61 """src="/images/icons/giticon.png"/>"""
62 )
62 )
63 response.mustcontain(
63 response.mustcontain(
64 """<img style="margin-bottom:2px" class="icon" """
64 """<img style="margin-bottom:2px" class="icon" """
65 """title="public repository" alt="public """
65 """title="public repository" alt="public """
66 """repository" src="/images/icons/lock_open.png"/>"""
66 """repository" src="/images/icons/lock_open.png"/>"""
67 )
67 )
68
68
69 # clone url...
69 # clone url...
70 response.mustcontain("""<input style="width:80%%;margin-left:105px" type="text" id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"/>""" % GIT_REPO)
70 response.mustcontain('''id="clone_url" readonly="readonly" value="http://test_admin@localhost:80/%s"''' % GIT_REPO)
71 response.mustcontain("""<input style="display:none;width:80%%;margin-left:105px" type="text" id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"/>""" % ID)
71 response.mustcontain('''id="clone_url_id" readonly="readonly" value="http://test_admin@localhost:80/_%s"''' % ID)
72
72
73 def test_index_by_id_hg(self):
73 def test_index_by_id_hg(self):
74 self.log_user()
74 self.log_user()
75 ID = Repository.get_by_repo_name(HG_REPO).repo_id
75 ID = Repository.get_by_repo_name(HG_REPO).repo_id
76 response = self.app.get(url(controller='summary',
76 response = self.app.get(url(controller='summary',
77 action='index',
77 action='index',
78 repo_name='_%s' % ID))
78 repo_name='_%s' % ID))
79
79
80 #repo type
80 #repo type
81 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
81 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
82 """title="Mercurial repository" alt="Mercurial """
82 """title="Mercurial repository" alt="Mercurial """
83 """repository" src="/images/icons/hgicon.png"/>""")
83 """repository" src="/images/icons/hgicon.png"/>""")
84 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
84 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
85 """title="public repository" alt="public """
85 """title="public repository" alt="public """
86 """repository" src="/images/icons/lock_open.png"/>""")
86 """repository" src="/images/icons/lock_open.png"/>""")
87
87
88 def test_index_by_repo_having_id_path_in_name_hg(self):
88 def test_index_by_repo_having_id_path_in_name_hg(self):
89 self.log_user()
89 self.log_user()
90 _make_repo(name='repo_1')
90 _make_repo(name='repo_1')
91 Session().commit()
91 Session().commit()
92 response = self.app.get(url(controller='summary',
92 response = self.app.get(url(controller='summary',
93 action='index',
93 action='index',
94 repo_name='repo_1'))
94 repo_name='repo_1'))
95
95
96 try:
96 try:
97 response.mustcontain("""repo_1""")
97 response.mustcontain("""repo_1""")
98 finally:
98 finally:
99 RepoModel().delete(Repository.get_by_repo_name('repo_1'))
99 RepoModel().delete(Repository.get_by_repo_name('repo_1'))
100 Session().commit()
100 Session().commit()
101
101
102 def test_index_by_id_git(self):
102 def test_index_by_id_git(self):
103 self.log_user()
103 self.log_user()
104 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
104 ID = Repository.get_by_repo_name(GIT_REPO).repo_id
105 response = self.app.get(url(controller='summary',
105 response = self.app.get(url(controller='summary',
106 action='index',
106 action='index',
107 repo_name='_%s' % ID))
107 repo_name='_%s' % ID))
108
108
109 #repo type
109 #repo type
110 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
110 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
111 """title="Git repository" alt="Git """
111 """title="Git repository" alt="Git """
112 """repository" src="/images/icons/giticon.png"/>""")
112 """repository" src="/images/icons/giticon.png"/>""")
113 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
113 response.mustcontain("""<img style="margin-bottom:2px" class="icon" """
114 """title="public repository" alt="public """
114 """title="public repository" alt="public """
115 """repository" src="/images/icons/lock_open.png"/>""")
115 """repository" src="/images/icons/lock_open.png"/>""")
116
116
117 def _enable_stats(self):
117 def _enable_stats(self):
118 r = Repository.get_by_repo_name(HG_REPO)
118 r = Repository.get_by_repo_name(HG_REPO)
119 r.enable_statistics = True
119 r.enable_statistics = True
120 self.Session.add(r)
120 self.Session.add(r)
121 self.Session.commit()
121 self.Session.commit()
General Comments 0
You need to be logged in to leave comments. Login now