Changeset - 491961dfd0c8
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2016-02-10 18:30:27
thomas.de.schampheleire@gmail.com
pytest migration: files: convert to TestControllerPytest and parametrize

Migrate the 'files' tests to pytest and its parametrize decorator.
The syntax of this decorator is slightly different: a first argument is a
comma-separated string with the method argument names for which the values
are provided as second argument.
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_files.py
Show inline comments
 
@@ -21,13 +21,13 @@ def _set_downloads(repo_name, set_to):
 
    repo = Repository.get_by_repo_name(repo_name)
 
    repo.enable_downloads = set_to
 
    Session().add(repo)
 
    Session().commit()
 

	
 

	
 
class TestFilesController(TestController):
 
class TestFilesController(TestControllerPytest):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name=HG_REPO,
 
                                    revision='tip',
 
@@ -344,13 +344,13 @@ removed extra unicode conversion in diff
 
                                    '_authentication_token': self.authentication_token(),
 
                                 },
 
                                 status=302)
 

	
 
        self.checkSessionFlash(response, 'No filename')
 

	
 
    @parameterized.expand([
 
    @parametrize('location,filename', [
 
        ('/abs', 'foo'),
 
        ('../rel', 'foo'),
 
        ('file/../foo', 'foo'),
 
    ])
 
    def test_add_file_into_hg_bad_filenames(self, location, filename):
 
        self.log_user()
 
@@ -364,13 +364,13 @@ removed extra unicode conversion in diff
 
                                    '_authentication_token': self.authentication_token(),
 
                                 },
 
                                 status=302)
 

	
 
        self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path')
 

	
 
    @parameterized.expand([
 
    @parametrize('cnt,location,filename', [
 
        (1, '', 'foo.txt'),
 
        (2, 'dir', 'foo.rst'),
 
        (3, 'rel/dir', 'foo.bar'),
 
    ])
 
    def test_add_file_into_hg(self, cnt, location, filename):
 
        self.log_user()
 
@@ -420,13 +420,13 @@ removed extra unicode conversion in diff
 
                                    '_authentication_token': self.authentication_token(),
 
                                 },
 
                                 status=302)
 

	
 
        self.checkSessionFlash(response, 'No filename')
 

	
 
    @parameterized.expand([
 
    @parametrize('location,filename', [
 
        ('/abs', 'foo'),
 
        ('../rel', 'foo'),
 
        ('file/../foo', 'foo'),
 
    ])
 
    def test_add_file_into_git_bad_filenames(self, location, filename):
 
        self.log_user()
 
@@ -440,13 +440,13 @@ removed extra unicode conversion in diff
 
                                    '_authentication_token': self.authentication_token(),
 
                                 },
 
                                 status=302)
 

	
 
        self.checkSessionFlash(response, 'Location must be relative path and must not contain .. in path')
 

	
 
    @parameterized.expand([
 
    @parametrize('cnt,location,filename', [
 
        (1, '', 'foo.txt'),
 
        (2, 'dir', 'foo.rst'),
 
        (3, 'rel/dir', 'foo.bar'),
 
    ])
 
    def test_add_file_into_git(self, cnt, location, filename):
 
        self.log_user()
0 comments (0 inline, 0 general)