Mercurial > kallithea
changeset 5910:313930ae35ad
pytest migration: other: convert to TestControllerPytest
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 06 May 2016 21:21:50 +0200 |
parents | ab36d9a31a2d |
children | fed636881606 |
files | kallithea/tests/other/manual_test_vcs_operations.py kallithea/tests/other/test_libs.py kallithea/tests/other/test_mail.py kallithea/tests/other/test_validators.py |
diffstat | 4 files changed, 18 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/tests/other/manual_test_vcs_operations.py Fri May 06 21:20:56 2016 +0200 +++ b/kallithea/tests/other/manual_test_vcs_operations.py Fri May 06 21:21:50 2016 +0200 @@ -166,14 +166,14 @@ assert 'master -> master' in stderr -class TestVCSOperations(BaseTestCase): +class TestVCSOperations(TestControllerPytest): @classmethod def setup_class(cls): #DISABLE ANONYMOUS ACCESS set_anonymous_access(False) - def setUp(self): + def setup_method(self, method): r = Repository.get_by_repo_name(GIT_REPO) Repository.unlock(r) r.enable_locking = False
--- a/kallithea/tests/other/test_libs.py Fri May 06 21:20:56 2016 +0200 +++ b/kallithea/tests/other/test_libs.py Fri May 06 21:21:50 2016 +0200 @@ -67,19 +67,20 @@ ] -class TestLibs(BaseTestCase): +class TestLibs(TestControllerPytest): - @parameterized.expand(TEST_URLS) + @parametrize('test_url,expected,expected_creds', TEST_URLS) def test_uri_filter(self, test_url, expected, expected_creds): from kallithea.lib.utils2 import uri_filter self.assertEqual(uri_filter(test_url), expected) - @parameterized.expand(TEST_URLS) + @parametrize('test_url,expected,expected_creds', TEST_URLS) def test_credentials_filter(self, test_url, expected, expected_creds): from kallithea.lib.utils2 import credentials_filter self.assertEqual(credentials_filter(test_url), expected_creds) - @parameterized.expand([('t', True), + @parametrize('str_bool,expected', [ + ('t', True), ('true', True), ('y', True), ('yes', True), @@ -116,7 +117,7 @@ 'marian.user', 'marco-polo', 'marco_polo', 'world']) self.assertEqual(expected, set(extract_mentioned_usernames(sample))) - @parameterized.expand([ + @parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds= -1), u'1 second ago'), (dict(seconds= -60 * 2), u'2 minutes ago'), @@ -139,7 +140,7 @@ delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) self.assertEqual(age(n + delt(**age_args), now=n), expected) - @parameterized.expand([ + @parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds= -1), u'1 second ago'), (dict(seconds= -60 * 2), u'2 minutes ago'), @@ -163,7 +164,7 @@ delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) self.assertEqual(age(n + delt(**age_args), show_short_version=True, now=n), expected) - @parameterized.expand([ + @parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds=1), u'in 1 second'), (dict(seconds=60 * 2), u'in 2 minutes'), @@ -248,7 +249,7 @@ grav = gravatar_url(email_address=em, size=24) assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) - @parameterized.expand([ + @parametrize('tmpl,repo_name,overrides,prefix,expected', [ (Repository.DEFAULT_CLONE_URI, 'group/repo1', {}, '', 'http://vps1:8000/group/repo1'), (Repository.DEFAULT_CLONE_URI, 'group/repo1', {'user': 'username'}, '', 'http://username@vps1:8000/group/repo1'), (Repository.DEFAULT_CLONE_URI, 'group/repo1', {}, '/prefix', 'http://vps1:8000/prefix/group/repo1'), @@ -285,7 +286,7 @@ return tmpl % (url_ or '/some-url', _url) return URL_PAT.sub(url_func, text) - @parameterized.expand([ + @parametrize('sample,expected', [ ("", ""), ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68", @@ -323,7 +324,7 @@ from kallithea.lib.helpers import urlify_changesets self.assertEqual(urlify_changesets(sample, 'repo_name'), expected) - @parameterized.expand([ + @parametrize('sample,expected,url_', [ ("", "", ""), @@ -350,7 +351,7 @@ tmpl="""<a href="%s">%s</a>""", url_=url_) self.assertEqual(urlify_text(sample), expected) - @parameterized.expand([ + @parametrize('test,expected', [ ("", None), ("/_2", '2'), ("_2", '2'),
--- a/kallithea/tests/other/test_mail.py Fri May 06 21:20:56 2016 +0200 +++ b/kallithea/tests/other/test_mail.py Fri May 06 21:21:50 2016 +0200 @@ -21,7 +21,7 @@ pass @mock.patch('kallithea.lib.rcmail.smtp_mailer.smtplib', smtplib_mock) -class TestMail(BaseTestCase): +class TestMail(TestControllerPytest): def test_send_mail_trivial(self): mailserver = 'smtp.mailserver.org'
--- a/kallithea/tests/other/test_validators.py Fri May 06 21:20:56 2016 +0200 +++ b/kallithea/tests/other/test_validators.py Fri May 06 21:21:50 2016 +0200 @@ -14,12 +14,9 @@ fixture = Fixture() -class TestRepoGroups(BaseTestCase): +class TestRepoGroups(TestControllerPytest): - def setUp(self): - pass - - def tearDown(self): + def teardown_method(self, method): Session.remove() def test_Message_extractor(self): @@ -164,7 +161,7 @@ # this uses ValidRepoName validator assert True - @parameterized.expand([ + @parametrize('name,expected', [ ('test', 'test'), ('lolz!', 'lolz'), (' aavv', 'aavv'), ('ala ma kota', 'ala-ma-kota'), ('@nooo', 'nooo'), ('$!haha lolz !', 'haha-lolz'), ('$$$$$', ''), ('{}OK!', 'OK'),