##// END OF EJS Templates
Use only mustcontain for testing response body
marcink -
r3646:63e49418 beta
parent child Browse files
Show More
@@ -33,6 +33,7 b' from paste.script.appinstall import Setu'
33 from pylons import config, url
33 from pylons import config, url
34 from routes.util import URLGenerator
34 from routes.util import URLGenerator
35 from webtest import TestApp
35 from webtest import TestApp
36 from nose.plugins.skip import SkipTest
36
37
37 from rhodecode import is_windows
38 from rhodecode import is_windows
38 from rhodecode.model.meta import Session
39 from rhodecode.model.meta import Session
@@ -51,6 +52,7 b' log = logging.getLogger(__name__)'
51
52
52 __all__ = [
53 __all__ = [
53 'parameterized', 'environ', 'url', 'get_new_dir', 'TestController',
54 'parameterized', 'environ', 'url', 'get_new_dir', 'TestController',
55 'SkipTest',
54 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO',
56 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO',
55 'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
57 'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
56 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
58 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
@@ -1,6 +1,5 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2 from rhodecode.model.db import RhodeCodeSetting
2 from rhodecode.model.db import RhodeCodeSetting
3 from nose.plugins.skip import SkipTest
4
3
5 skip_ldap_test = False
4 skip_ldap_test = False
6 try:
5 try:
@@ -17,7 +16,7 b' class TestLdapSettingsController(TestCon'
17 self.log_user()
16 self.log_user()
18 response = self.app.get(url(controller='admin/ldap_settings',
17 response = self.app.get(url(controller='admin/ldap_settings',
19 action='index'))
18 action='index'))
20 self.assertTrue('LDAP administration' in response.body)
19 response.mustcontain('LDAP administration')
21
20
22 def test_ldap_save_settings(self):
21 def test_ldap_save_settings(self):
23 self.log_user()
22 self.log_user()
@@ -72,14 +71,12 b' class TestLdapSettingsController(TestCon'
72 'ldap_attr_lastname':'',
71 'ldap_attr_lastname':'',
73 'ldap_attr_email':'' })
72 'ldap_attr_email':'' })
74
73
75 self.assertTrue("""<span class="error-message">The LDAP Login"""
74 response.mustcontain("""<span class="error-message">The LDAP Login"""
76 """ attribute of the CN must be specified""" in
75 """ attribute of the CN must be specified""")
77 response.body)
78
76
79
77
80
78 response.mustcontain("""<span class="error-message">Please """
81 self.assertTrue("""<span class="error-message">Please """
79 """enter a number</span>""")
82 """enter a number</span>""" in response.body)
83
80
84 def test_ldap_login(self):
81 def test_ldap_login(self):
85 pass
82 pass
@@ -22,8 +22,7 b' class TestNotificationsController(TestCo'
22 u1 = u1.user_id
22 u1 = u1.user_id
23
23
24 response = self.app.get(url('notifications'))
24 response = self.app.get(url('notifications'))
25 self.assertTrue('''<div class="table">No notifications here yet</div>'''
25 response.mustcontain('<div class="table">No notifications here yet</div>')
26 in response.body)
27
26
28 cur_user = self._get_logged_user()
27 cur_user = self._get_logged_user()
29
28
@@ -32,7 +31,7 b' class TestNotificationsController(TestCo'
32 recipients=[cur_user])
31 recipients=[cur_user])
33 self.Session().commit()
32 self.Session().commit()
34 response = self.app.get(url('notifications'))
33 response = self.app.get(url('notifications'))
35 self.assertTrue(u'test_notification_1' in response.body)
34 response.mustcontain(u'test_notification_1')
36
35
37 # def test_index_as_xml(self):
36 # def test_index_as_xml(self):
38 # response = self.app.get(url('formatted_notifications', format='xml'))
37 # response = self.app.get(url('formatted_notifications', format='xml'))
@@ -90,8 +90,7 b' class TestAdminSettingsController(TestCo'
90 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
90 .get_app_settings()['rhodecode_ga_code'], new_ga_code)
91
91
92 response = response.follow()
92 response = response.follow()
93 self.assertFalse("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code
93 response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])
94 in response.body)
95
94
96 def test_title_change(self):
95 def test_title_change(self):
97 self.log_user()
96 self.log_user()
@@ -120,7 +119,7 b' class TestAdminSettingsController(TestCo'
120 self.log_user()
119 self.log_user()
121 response = self.app.get(url('admin_settings_my_account'))
120 response = self.app.get(url('admin_settings_my_account'))
122
121
123 self.assertTrue('value="test_admin' in response.body)
122 response.mustcontain('value="test_admin')
124
123
125 @parameterized.expand([('firstname', 'new_username'),
124 @parameterized.expand([('firstname', 'new_username'),
126 ('lastname', 'new_username'),
125 ('lastname', 'new_username'),
@@ -217,7 +216,7 b' class TestAdminSettingsController(TestCo'
217 repo = Repository.get_by_repo_name(HG_REPO)
216 repo = Repository.get_by_repo_name(HG_REPO)
218 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
217 response = self.app.get(url('edit_repo', repo_name=HG_REPO))
219 opt = """<option value="%s">vcs_test_git</option>""" % repo.repo_id
218 opt = """<option value="%s">vcs_test_git</option>""" % repo.repo_id
220 assert opt not in response.body
219 response.mustcontain(no=[opt])
221
220
222 def test_set_fork_of_repo(self):
221 def test_set_fork_of_repo(self):
223 self.log_user()
222 self.log_user()
@@ -1,13 +1,24 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2
2
3
3 class TestFollowersController(TestController):
4 class TestFollowersController(TestController):
4
5
5 def test_index(self):
6 def test_index_hg(self):
6 self.log_user()
7 self.log_user()
7 repo_name = HG_REPO
8 repo_name = HG_REPO
8 response = self.app.get(url(controller='followers',
9 response = self.app.get(url(controller='followers',
9 action='followers',
10 action='followers',
10 repo_name=repo_name))
11 repo_name=repo_name))
11
12
12 self.assertTrue("""test_admin""" in response.body)
13 response.mustcontain("""test_admin""")
13 self.assertTrue("""Started following""" in response.body)
14 response.mustcontain("""Started following""")
15
16 def test_index_git(self):
17 self.log_user()
18 repo_name = GIT_REPO
19 response = self.app.get(url(controller='followers',
20 action='followers',
21 repo_name=repo_name))
22
23 response.mustcontain("""test_admin""")
24 response.mustcontain("""Started following""")
@@ -27,7 +27,7 b' class TestForksController(TestController'
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 response.mustcontain("""There are no forks yet""")
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,
@@ -135,7 +135,7 b' class TestForksController(TestController'
135 response = self.app.get(url(controller='summary', action='index',
135 response = self.app.get(url(controller='summary', action='index',
136 repo_name=fork_name))
136 repo_name=fork_name))
137
137
138 self.assertTrue('Fork of %s' % repo_name in response.body)
138 response.mustcontain('Fork of %s' % repo_name)
139
139
140 def test_zz_fork_permission_page(self):
140 def test_zz_fork_permission_page(self):
141 usr = self.log_user(self.username, self.password)['user_id']
141 usr = self.log_user(self.username, self.password)['user_id']
@@ -1,6 +1,5 b''
1 import os
1 import os
2 from rhodecode.tests import *
2 from rhodecode.tests import *
3 from nose.plugins.skip import SkipTest
4
3
5
4
6 class TestSearchController(TestController):
5 class TestSearchController(TestController):
@@ -9,8 +8,7 b' class TestSearchController(TestControlle'
9 self.log_user()
8 self.log_user()
10 response = self.app.get(url(controller='search', action='index'))
9 response = self.app.get(url(controller='search', action='index'))
11
10
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
11 response.mustcontain('class="small" id="q" name="q" type="text"')
13 response.body)
14 # Test response...
12 # Test response...
15
13
16 def test_empty_search(self):
14 def test_empty_search(self):
@@ -20,8 +18,8 b' class TestSearchController(TestControlle'
20 self.log_user()
18 self.log_user()
21 response = self.app.get(url(controller='search', action='index'),
19 response = self.app.get(url(controller='search', action='index'),
22 {'q': HG_REPO})
20 {'q': HG_REPO})
23 self.assertTrue('There is no index to search in. '
21 response.mustcontain('There is no index to search in. '
24 'Please run whoosh indexer' in response.body)
22 'Please run whoosh indexer')
25
23
26 def test_normal_search(self):
24 def test_normal_search(self):
27 self.log_user()
25 self.log_user()
General Comments 0
You need to be logged in to leave comments. Login now