changeset 3646:63e49418a4cc beta

Use only mustcontain for testing response body
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 31 Mar 2013 21:44:27 +0200
parents aef5f5ce5ead
children 8a86836fad64
files rhodecode/tests/__init__.py rhodecode/tests/functional/test_admin_ldap_settings.py rhodecode/tests/functional/test_admin_notifications.py rhodecode/tests/functional/test_admin_settings.py rhodecode/tests/functional/test_followers.py rhodecode/tests/functional/test_forks.py rhodecode/tests/functional/test_search.py
diffstat 7 files changed, 31 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/tests/__init__.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/__init__.py	Sun Mar 31 21:44:27 2013 +0200
@@ -33,6 +33,7 @@
 from pylons import config, url
 from routes.util import URLGenerator
 from webtest import TestApp
+from nose.plugins.skip import SkipTest
 
 from rhodecode import is_windows
 from rhodecode.model.meta import Session
@@ -51,6 +52,7 @@
 
 __all__ = [
     'parameterized', 'environ', 'url', 'get_new_dir', 'TestController',
+    'SkipTest',
     'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO',
     'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
     'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
--- a/rhodecode/tests/functional/test_admin_ldap_settings.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_admin_ldap_settings.py	Sun Mar 31 21:44:27 2013 +0200
@@ -1,6 +1,5 @@
 from rhodecode.tests import *
 from rhodecode.model.db import RhodeCodeSetting
-from nose.plugins.skip import SkipTest
 
 skip_ldap_test = False
 try:
@@ -17,7 +16,7 @@
         self.log_user()
         response = self.app.get(url(controller='admin/ldap_settings',
                                     action='index'))
-        self.assertTrue('LDAP administration' in response.body)
+        response.mustcontain('LDAP administration')
 
     def test_ldap_save_settings(self):
         self.log_user()
@@ -72,14 +71,12 @@
                     'ldap_attr_lastname':'',
                     'ldap_attr_email':'' })
 
-        self.assertTrue("""<span class="error-message">The LDAP Login"""
-                        """ attribute of the CN must be specified""" in
-                        response.body)
+        response.mustcontain("""<span class="error-message">The LDAP Login"""
+                             """ attribute of the CN must be specified""")
 
 
-
-        self.assertTrue("""<span class="error-message">Please """
-                        """enter a number</span>""" in response.body)
+        response.mustcontain("""<span class="error-message">Please """
+                             """enter a number</span>""")
 
     def test_ldap_login(self):
         pass
--- a/rhodecode/tests/functional/test_admin_notifications.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_admin_notifications.py	Sun Mar 31 21:44:27 2013 +0200
@@ -22,8 +22,7 @@
         u1 = u1.user_id
 
         response = self.app.get(url('notifications'))
-        self.assertTrue('''<div class="table">No notifications here yet</div>'''
-                        in response.body)
+        response.mustcontain('<div class="table">No notifications here yet</div>')
 
         cur_user = self._get_logged_user()
 
@@ -32,7 +31,7 @@
                                    recipients=[cur_user])
         self.Session().commit()
         response = self.app.get(url('notifications'))
-        self.assertTrue(u'test_notification_1' in response.body)
+        response.mustcontain(u'test_notification_1')
 
 #    def test_index_as_xml(self):
 #        response = self.app.get(url('formatted_notifications', format='xml'))
--- a/rhodecode/tests/functional/test_admin_settings.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_admin_settings.py	Sun Mar 31 21:44:27 2013 +0200
@@ -90,8 +90,7 @@
                         .get_app_settings()['rhodecode_ga_code'], new_ga_code)
 
         response = response.follow()
-        self.assertFalse("""_gaq.push(['_setAccount', '%s']);""" % new_ga_code
-                         in response.body)
+        response.mustcontain(no=["_gaq.push(['_setAccount', '%s']);" % new_ga_code])
 
     def test_title_change(self):
         self.log_user()
@@ -120,7 +119,7 @@
         self.log_user()
         response = self.app.get(url('admin_settings_my_account'))
 
-        self.assertTrue('value="test_admin' in response.body)
+        response.mustcontain('value="test_admin')
 
     @parameterized.expand([('firstname', 'new_username'),
                            ('lastname', 'new_username'),
@@ -217,7 +216,7 @@
         repo = Repository.get_by_repo_name(HG_REPO)
         response = self.app.get(url('edit_repo', repo_name=HG_REPO))
         opt = """<option value="%s">vcs_test_git</option>""" % repo.repo_id
-        assert opt not in response.body
+        response.mustcontain(no=[opt])
 
     def test_set_fork_of_repo(self):
         self.log_user()
--- a/rhodecode/tests/functional/test_followers.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_followers.py	Sun Mar 31 21:44:27 2013 +0200
@@ -1,13 +1,24 @@
 from rhodecode.tests import *
 
+
 class TestFollowersController(TestController):
 
-    def test_index(self):
+    def test_index_hg(self):
         self.log_user()
         repo_name = HG_REPO
         response = self.app.get(url(controller='followers',
                                     action='followers',
                                     repo_name=repo_name))
 
-        self.assertTrue("""test_admin""" in response.body)
-        self.assertTrue("""Started following""" in response.body)
+        response.mustcontain("""test_admin""")
+        response.mustcontain("""Started following""")
+
+    def test_index_git(self):
+        self.log_user()
+        repo_name = GIT_REPO
+        response = self.app.get(url(controller='followers',
+                                    action='followers',
+                                    repo_name=repo_name))
+
+        response.mustcontain("""test_admin""")
+        response.mustcontain("""Started following""")
--- a/rhodecode/tests/functional/test_forks.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_forks.py	Sun Mar 31 21:44:27 2013 +0200
@@ -27,7 +27,7 @@
         response = self.app.get(url(controller='forks', action='forks',
                                     repo_name=repo_name))
 
-        self.assertTrue("""There are no forks yet""" in response.body)
+        response.mustcontain("""There are no forks yet""")
 
     def test_no_permissions_to_fork(self):
         usr = self.log_user(TEST_USER_REGULAR_LOGIN,
@@ -135,7 +135,7 @@
         response = self.app.get(url(controller='summary', action='index',
                                     repo_name=fork_name))
 
-        self.assertTrue('Fork of %s' % repo_name in response.body)
+        response.mustcontain('Fork of %s' % repo_name)
 
     def test_zz_fork_permission_page(self):
         usr = self.log_user(self.username, self.password)['user_id']
--- a/rhodecode/tests/functional/test_search.py	Sun Mar 31 21:31:36 2013 +0200
+++ b/rhodecode/tests/functional/test_search.py	Sun Mar 31 21:44:27 2013 +0200
@@ -1,6 +1,5 @@
 import os
 from rhodecode.tests import *
-from nose.plugins.skip import SkipTest
 
 
 class TestSearchController(TestController):
@@ -9,8 +8,7 @@
         self.log_user()
         response = self.app.get(url(controller='search', action='index'))
 
-        self.assertTrue('class="small" id="q" name="q" type="text"' in
-                        response.body)
+        response.mustcontain('class="small" id="q" name="q" type="text"')
         # Test response...
 
     def test_empty_search(self):
@@ -20,8 +18,8 @@
             self.log_user()
             response = self.app.get(url(controller='search', action='index'),
                                     {'q': HG_REPO})
-            self.assertTrue('There is no index to search in. '
-                            'Please run whoosh indexer' in response.body)
+            response.mustcontain('There is no index to search in. '
+                                 'Please run whoosh indexer')
 
     def test_normal_search(self):
         self.log_user()