Changeset - 72e8508d9758
[Not reviewed]
default
0 3 0
Thomas De Schampheleire - 10 years ago 2016-04-25 13:35:21
thomas.de.schampheleire@gmail.com
pytest migration: convert functional tests with setup/teardown and parametrization
3 files changed with 16 insertions and 16 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_admin_users.py
Show inline comments
 
@@ -26,7 +26,7 @@ from kallithea.model.meta import Session
 
fixture = Fixture()
 

	
 

	
 
class TestAdminUsersController(TestController):
 
class TestAdminUsersController(TestControllerPytest):
 
    test_user_1 = 'testme'
 

	
 
    @classmethod
 
@@ -108,7 +108,7 @@ class TestAdminUsersController(TestContr
 
        self.log_user()
 
        response = self.app.get(url('new_user'))
 

	
 
    @parameterized.expand(
 
    @parametrize('name,attrs',
 
        [('firstname', {'firstname': 'new_username'}),
 
         ('lastname', {'lastname': 'new_username'}),
 
         ('admin', {'admin': True}),
 
@@ -387,7 +387,7 @@ class TestAdminUsersController(TestContr
 
        response = self.app.get(url('edit_user_ips', id=user.user_id))
 
        response.mustcontain('All IP addresses are allowed')
 

	
 
    @parameterized.expand([
 
    @parametrize('test_name,ip,ip_range,failure', [
 
        ('127/24', '127.0.0.1/24', '127.0.0.0 - 127.0.0.255', False),
 
        ('10/32', '10.0.0.10/32', '10.0.0.10 - 10.0.0.10', False),
 
        ('0/16', '0.0.0.0/16', '0.0.0.0 - 0.0.255.255', False),
 
@@ -449,7 +449,7 @@ class TestAdminUsersController(TestContr
 
        response.mustcontain(user.api_key)
 
        response.mustcontain('Expires: Never')
 

	
 
    @parameterized.expand([
 
    @parametrize('desc,lifetime', [
 
        ('forever', -1),
 
        ('5mins', 60*5),
 
        ('30days', 60*60*24*30),
kallithea/tests/functional/test_login.py
Show inline comments
 
@@ -19,8 +19,8 @@ from kallithea.model.user import UserMod
 
fixture = Fixture()
 

	
 

	
 
class TestLoginController(TestController):
 
    def setUp(self):
 
class TestLoginController(TestControllerPytest):
 
    def setup_method(self, method):
 
        remove_all_notifications()
 
        self.assertEqual(Notification.query().all(), [])
 

	
 
@@ -111,7 +111,7 @@ class TestLoginController(TestController
 
        response = self.app.get(url(controller='login', action='index'))
 
        self.assertNotIn('authuser', response.session)
 

	
 
    @parameterized.expand([
 
    @parametrize('url_came_from', [
 
          ('data:text/html,<script>window.alert("xss")</script>',),
 
          ('mailto:test@example.com',),
 
          ('file:///etc/passwd',),
 
@@ -146,7 +146,7 @@ class TestLoginController(TestController
 

	
 
    # verify that get arguments are correctly passed along login redirection
 

	
 
    @parameterized.expand([
 
    @parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, (('foo', 'one'), ('bar', 'two'))),
 
        ({'blue': u'blå'.encode('utf-8'), 'green':u'grøn'},
 
             (('blue', u'blå'.encode('utf-8')), ('green', u'grøn'.encode('utf-8')))),
 
@@ -162,7 +162,7 @@ class TestLoginController(TestController
 
            for encoded in args_encoded:
 
                self.assertIn(encoded, came_from_qs)
 

	
 
    @parameterized.expand([
 
    @parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
@@ -174,7 +174,7 @@ class TestLoginController(TestController
 
        for encoded in args_encoded:
 
            self.assertIn(encoded, came_from)
 

	
 
    @parameterized.expand([
 
    @parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
@@ -188,7 +188,7 @@ class TestLoginController(TestController
 
        for encoded in args_encoded:
 
            self.assertIn(encoded, response.location)
 

	
 
    @parameterized.expand([
 
    @parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
@@ -435,7 +435,7 @@ class TestLoginController(TestController
 
        config = {'api_access_controllers_whitelist': values or []}
 
        return config
 

	
 
    @parameterized.expand([
 
    @parametrize('test_name,api_key', [
 
        ('none', None),
 
        ('empty_string', ''),
 
        ('fake_number', '123456'),
 
@@ -456,7 +456,7 @@ class TestLoginController(TestController
 
                                 repo_name=HG_REPO, revision='tip', api_key=api_key),
 
                             status=403)
 

	
 
    @parameterized.expand([
 
    @parametrize('test_name,api_key,code', [
 
        ('none', None, 302),
 
        ('empty_string', '', 302),
 
        ('fake_number', '123456', 302),
kallithea/tests/functional/test_my_account.py
Show inline comments
 
@@ -10,7 +10,7 @@ from kallithea.model.meta import Session
 
fixture = Fixture()
 

	
 

	
 
class TestMyAccountController(TestController):
 
class TestMyAccountController(TestControllerPytest):
 
    test_user_1 = 'testme'
 

	
 
    @classmethod
 
@@ -86,7 +86,7 @@ class TestMyAccountController(TestContro
 
        response.mustcontain('No additional emails specified')
 

	
 

	
 
    @parameterized.expand(
 
    @parametrize('name,attrs',
 
        [('firstname', {'firstname': 'new_username'}),
 
         ('lastname', {'lastname': 'new_username'}),
 
         ('admin', {'admin': True}),
 
@@ -192,7 +192,7 @@ class TestMyAccountController(TestContro
 
        response.mustcontain(user.api_key)
 
        response.mustcontain('Expires: Never')
 

	
 
    @parameterized.expand([
 
    @parametrize('desc,lifetime', [
 
        ('forever', -1),
 
        ('5mins', 60*5),
 
        ('30days', 60*60*24*30),
0 comments (0 inline, 0 general)