Commits

Marcin Kuzminski committed 53aa1ee

updated tests for new version 6char password etc...

Comments (0)

Files changed (6)

 import ConfigParser
 root = os.getcwd()
 
-PYLONS_CONFIG_NAME = 'production.ini'
+PYLONS_CONFIG_NAME = 'test.ini'
 
 sys.path.append(root)
 config = ConfigParser.ConfigParser({'here':root})
 
 #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

pylons_app/lib/db_manage.py

             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)
             
         
     

pylons_app/tests/__init__.py

 
         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()

pylons_app/tests/functional/test_admin_settings.py

         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,))
         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,))
         
         
     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,))

pylons_app/tests/functional/test_login.py

         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()
         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'))
         
         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
         
         
         

pylons_app/tests/functional/test_settings.py

+from pylons_app.model.db import Repository
 from pylons_app.tests import *
 
 class TestSettingsController(TestController):
         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