diff --git a/rhodecode/tests/__init__.py b/rhodecode/tests/__init__.py --- a/rhodecode/tests/__init__.py +++ b/rhodecode/tests/__init__.py @@ -7,6 +7,9 @@ command. This module initializes the application via ``websetup`` (`paster setup-app`) and provides the base testing objects. """ +import os +from os.path import join as jn + from unittest import TestCase from paste.deploy import loadapp @@ -14,7 +17,7 @@ from paste.script.appinstall import Setu from pylons import config, url from routes.util import URLGenerator from webtest import TestApp -import os + from rhodecode.model import meta import logging @@ -24,19 +27,22 @@ log = logging.getLogger(__name__) import pylons.test __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', - 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', ] + 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', + 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS' ] # Invoke websetup with the current config file #SetupCommand('setup-app').run([config_file]) ##RUNNING DESIRED TESTS -#nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account - +# nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account +# nosetests --pdb --pdb-failures environ = {} #SOME GLOBALS FOR TESTS -TESTS_TMP_PATH = '/tmp' - +from tempfile import _RandomNameSequence +TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) +TEST_USER_ADMIN_LOGIN = 'test_admin' +TEST_USER_ADMIN_PASS = 'test12' HG_REPO = 'vcs_test_hg' GIT_REPO = 'vcs_test_git' @@ -58,15 +64,22 @@ class TestController(TestCase): self.index_location = config['app_conf']['index_dir'] TestCase.__init__(self, *args, **kwargs) - def log_user(self, username='test_admin', password='test12'): + def log_user(self, username=TEST_USER_ADMIN_LOGIN, + password=TEST_USER_ADMIN_PASS): response = self.app.post(url(controller='login', action='index'), {'username':username, 'password':password}) - print response if 'invalid user name' in response.body: - assert False, 'could not login using %s %s' % (username, password) + self.fail('could not login using %s %s' % (username, password)) + + self.assertEqual(response.status, '302 Found') + self.assertEqual(response.session['rhodecode_user'].username, username) + return response.follow() - assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status - assert response.session['rhodecode_user'].username == username, 'wrong logged in user got %s expected %s' % (response.session['rhodecode_user'].username, username) - return response.follow() + + + def checkSessionFlash(self, response, msg): + self.assertTrue('flash' in response.session) + self.assertTrue(msg in response.session['flash'][0][1]) +