diff --git a/celeryconfig.py b/celeryconfig.py --- a/celeryconfig.py +++ b/celeryconfig.py @@ -4,7 +4,7 @@ import os import ConfigParser root = os.getcwd() -PYLONS_CONFIG_NAME = 'production.ini' +PYLONS_CONFIG_NAME = 'test.ini' sys.path.append(root) config = ConfigParser.ConfigParser({'here':root}) @@ -40,6 +40,9 @@ CELERYD_MAX_TASKS_PER_CHILD = 3 #Tasks will never be sent to the queue, but executed locally instead. CELERY_ALWAYS_EAGER = False +if PYLONS_CONFIG_NAME == 'test.ini': + #auto eager for tests + CELERY_ALWAYS_EAGER = True #=============================================================================== # EMAIL SETTINGS diff --git a/pylons_app/lib/db_manage.py b/pylons_app/lib/db_manage.py --- a/pylons_app/lib/db_manage.py +++ b/pylons_app/lib/db_manage.py @@ -88,9 +88,9 @@ class DbManage(object): self.create_user(username, password, email, True) else: log.info('creating admin and regular test users') - self.create_user('test_admin', 'test', 'test_admin@mail.com', True) - self.create_user('test_regular', 'test', 'test_regular@mail.com', False) - self.create_user('test_regular2', 'test', 'test_regular2@mail.com', False) + self.create_user('test_admin', 'test12', 'test_admin@mail.com', True) + self.create_user('test_regular', 'test12', 'test_regular@mail.com', False) + self.create_user('test_regular2', 'test12', 'test_regular2@mail.com', False) diff --git a/pylons_app/tests/__init__.py b/pylons_app/tests/__init__.py --- a/pylons_app/tests/__init__.py +++ b/pylons_app/tests/__init__.py @@ -42,10 +42,10 @@ class TestController(TestCase): TestCase.__init__(self, *args, **kwargs) - def log_user(self, username='test_admin', password='test'): + def log_user(self, username='test_admin', password='test12'): response = self.app.post(url(controller='login', action='index'), {'username':username, 'password':password}) assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status - assert response.session['hg_app_user'].username == 'test_admin', 'wrong logged in user' + assert response.session['hg_app_user'].username == username, 'wrong logged in user got %s expected %s' % (response.session['hg_app_user'].username, username) return response.follow() diff --git a/pylons_app/tests/functional/test_admin_settings.py b/pylons_app/tests/functional/test_admin_settings.py --- a/pylons_app/tests/functional/test_admin_settings.py +++ b/pylons_app/tests/functional/test_admin_settings.py @@ -78,7 +78,7 @@ class TestSettingsController(TestControl response = self.app.post(url('admin_settings_my_account_update'), params=dict( _method='put', username='test_admin', - new_password='test', + new_password='test12', name='NewName', lastname='NewLastname', email=new_email,)) @@ -91,7 +91,7 @@ class TestSettingsController(TestControl response = self.app.post(url('admin_settings_my_account_update'), params=dict( _method='put', username='test_admin', - new_password='test', + new_password='test12', name='NewName', lastname='NewLastname', email=new_email,)) @@ -101,13 +101,13 @@ class TestSettingsController(TestControl def test_my_account_update_err(self): - self.log_user() + self.log_user('test_regular2', 'test12') new_email = 'newmail.pl' response = self.app.post(url('admin_settings_my_account_update'), params=dict( _method='put', - username='test_regular2', - new_password='test', + username='test_admin', + new_password='test12', name='NewName', lastname='NewLastname', email=new_email,)) diff --git a/pylons_app/tests/functional/test_login.py b/pylons_app/tests/functional/test_login.py --- a/pylons_app/tests/functional/test_login.py +++ b/pylons_app/tests/functional/test_login.py @@ -23,6 +23,7 @@ class TestLoginController(TestController response = self.app.post(url(controller='login', action='index'), {'username':'test_regular', 'password':'test'}) + print response assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status assert response.session['hg_app_user'].username == 'test_regular', 'wrong logged in user' response = response.follow() @@ -41,15 +42,23 @@ class TestLoginController(TestController assert 'Users administration' in response.body, 'No proper title in response' - def test_login_wrong(self): + def test_login_short_password(self): response = self.app.post(url(controller='login', action='index'), {'username':'error', 'password':'test'}) assert response.status == '200 OK', 'Wrong response from login page' + assert 'Enter a value 6 characters long or more' in response.body, 'No error password message in response' + + def test_login_wrong_username_password(self): + response = self.app.post(url(controller='login', action='index'), + {'username':'error', + 'password':'test12'}) + assert response.status == '200 OK', 'Wrong response from login page' + assert 'invalid user name' in response.body, 'No error username message in response' assert 'invalid password' in response.body, 'No error password message in response' - + def test_register(self): response = self.app.get(url(controller='login', action='register')) @@ -76,8 +85,7 @@ class TestLoginController(TestController assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status assert 'An email address must contain a single @' in response.body - assert 'Enter a value 3 characters long or more' in response.body - assert 'Please enter a value<' in response.body + assert 'Please enter a value' in response.body diff --git a/pylons_app/tests/functional/test_settings.py b/pylons_app/tests/functional/test_settings.py --- a/pylons_app/tests/functional/test_settings.py +++ b/pylons_app/tests/functional/test_settings.py @@ -1,3 +1,4 @@ +from pylons_app.model.db import Repository from pylons_app.tests import * class TestSettingsController(TestController): @@ -7,3 +8,40 @@ class TestSettingsController(TestControl response = self.app.get(url(controller='settings', action='index', repo_name='vcs_test')) # Test response... + + def test_fork(self): + self.log_user() + response = self.app.get(url(controller='settings', action='fork', + repo_name='vcs_test')) + + + def test_fork_create(self): + self.log_user() + fork_name = 'vcs_test_fork' + description = 'fork of vcs test' + repo_name = 'vcs_test' + response = self.app.post(url(controller='settings', action='fork_create', + repo_name=repo_name), + {'fork_name':fork_name, + 'description':description, + 'private':'False'}) + + + print response + + #test if we have a message that fork is ok + assert 'fork %s repository as %s task added' \ + % (repo_name, fork_name) in response.session['flash'][0], 'No flash message about fork' + + #test if the fork was created in the database + fork_repo = self.sa.query(Repository).filter(Repository.repo_name == fork_name).one() + + assert fork_repo.repo_name == fork_name, 'wrong name of repo name in new db fork repo' + assert fork_repo.fork.repo_name == repo_name, 'wron fork parrent' + + + #test if fork is visible in the list ? + response.follow() + + print response + assert False