diff --git a/kallithea/bin/kallithea_cli_ishell.py b/kallithea/bin/kallithea_cli_ishell.py
--- a/kallithea/bin/kallithea_cli_ishell.py
+++ b/kallithea/bin/kallithea_cli_ishell.py
@@ -25,7 +25,7 @@ from __future__ import print_function
import sys
import kallithea.bin.kallithea_cli_base as cli_base
-from kallithea.model.db import *
+from kallithea.model.db import * # these names will be directly available in the IPython shell
@cli_base.register_command(config_file_initialize_app=True)
diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py
--- a/kallithea/tests/api/api_base.py
+++ b/kallithea/tests/api/api_base.py
@@ -34,7 +34,7 @@ from kallithea.model.repo_group import R
from kallithea.model.scm import ScmModel
from kallithea.model.user import UserModel
from kallithea.model.user_group import UserGroupModel
-from kallithea.tests.base import *
+from kallithea.tests import base
from kallithea.tests.fixture import Fixture
@@ -75,15 +75,15 @@ def api_call(test_obj, params):
## helpers
def make_user_group(name=TEST_USER_GROUP):
- gr = fixture.create_user_group(name, cur_user=TEST_USER_ADMIN_LOGIN)
+ gr = fixture.create_user_group(name, cur_user=base.TEST_USER_ADMIN_LOGIN)
UserGroupModel().add_user_to_group(user_group=gr,
- user=TEST_USER_ADMIN_LOGIN)
+ user=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
return gr
def make_repo_group(name=TEST_REPO_GROUP):
- gr = fixture.create_repo_group(name, cur_user=TEST_USER_ADMIN_LOGIN)
+ gr = fixture.create_repo_group(name, cur_user=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
return gr
@@ -94,7 +94,7 @@ class _BaseTestApi(object):
@classmethod
def setup_class(cls):
- cls.usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ cls.usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
cls.apikey = cls.usr.api_key
cls.test_user = UserModel().create_or_update(
username='test-api',
@@ -230,10 +230,10 @@ class _BaseTestApi(object):
def test_api_get_user(self):
id_, params = _build_data(self.apikey, 'get_user',
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
- usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
ret = usr.get_api_data()
ret['permissions'] = AuthUser(dbuser=usr).permissions
@@ -252,7 +252,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'get_user')
response = api_call(self, params)
- usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
ret = usr.get_api_data()
ret['permissions'] = AuthUser(dbuser=usr).permissions
@@ -394,22 +394,22 @@ class _BaseTestApi(object):
def test_api_create_existing_user(self):
id_, params = _build_data(self.apikey, 'create_user',
- username=TEST_USER_ADMIN_LOGIN,
+ username=base.TEST_USER_ADMIN_LOGIN,
email='test@example.com',
password='trololo')
response = api_call(self, params)
- expected = "user `%s` already exist" % TEST_USER_ADMIN_LOGIN
+ expected = "user `%s` already exist" % base.TEST_USER_ADMIN_LOGIN
self._compare_error(id_, expected, given=response.body)
def test_api_create_user_with_existing_email(self):
id_, params = _build_data(self.apikey, 'create_user',
- username=TEST_USER_ADMIN_LOGIN + 'new',
- email=TEST_USER_REGULAR_EMAIL,
+ username=base.TEST_USER_ADMIN_LOGIN + 'new',
+ email=base.TEST_USER_REGULAR_EMAIL,
password='trololo')
response = api_call(self, params)
- expected = "email `%s` already exist" % TEST_USER_REGULAR_EMAIL
+ expected = "email `%s` already exist" % base.TEST_USER_REGULAR_EMAIL
self._compare_error(id_, expected, given=response.body)
def test_api_create_user(self):
@@ -525,7 +525,7 @@ class _BaseTestApi(object):
expected = ret
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,expected', [
+ @base.parametrize('name,expected', [
('firstname', 'new_username'),
('lastname', 'new_username'),
('email', 'new_username'),
@@ -558,22 +558,22 @@ class _BaseTestApi(object):
self._compare_ok(id_, expected, given=response.body)
def test_api_update_user_no_changed_params(self):
- usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
ret = jsonify(usr.get_api_data())
id_, params = _build_data(self.apikey, 'update_user',
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
ret = {
'msg': 'updated user ID:%s %s' % (
- usr.user_id, TEST_USER_ADMIN_LOGIN),
+ usr.user_id, base.TEST_USER_ADMIN_LOGIN),
'user': ret
}
expected = ret
self._compare_ok(id_, expected, given=response.body)
def test_api_update_user_by_user_id(self):
- usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
ret = jsonify(usr.get_api_data())
id_, params = _build_data(self.apikey, 'update_user',
userid=usr.user_id)
@@ -581,7 +581,7 @@ class _BaseTestApi(object):
response = api_call(self, params)
ret = {
'msg': 'updated user ID:%s %s' % (
- usr.user_id, TEST_USER_ADMIN_LOGIN),
+ usr.user_id, base.TEST_USER_ADMIN_LOGIN),
'user': ret
}
expected = ret
@@ -598,7 +598,7 @@ class _BaseTestApi(object):
@mock.patch.object(UserModel, 'update_user', crash)
def test_api_update_user_when_exception_happens(self):
- usr = User.get_by_username(TEST_USER_ADMIN_LOGIN)
+ usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
ret = jsonify(usr.get_api_data())
id_, params = _build_data(self.apikey, 'update_user',
userid=usr.user_id)
@@ -658,7 +658,7 @@ class _BaseTestApi(object):
assert u"v0.2.0" in response.json[u'result'][u'tags']
assert u'pull_requests' in response.json[u'result']
- @parametrize('grant_perm', [
+ @base.parametrize('grant_perm', [
('repository.admin'),
('repository.write'),
('repository.read'),
@@ -755,7 +755,7 @@ class _BaseTestApi(object):
self._compare_ok(id_, expected, given=response.body)
- @parametrize('name,ret_type', [
+ @base.parametrize('name,ret_type', [
('all', 'all'),
('dirs', 'dirs'),
('files', 'files'),
@@ -810,7 +810,7 @@ class _BaseTestApi(object):
% (','.join(sorted(['files', 'dirs', 'all']))))
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,ret_type,grant_perm', [
+ @base.parametrize('name,ret_type,grant_perm', [
('all', 'all', 'repository.write'),
('dirs', 'dirs', 'repository.admin'),
('files', 'files', 'repository.read'),
@@ -841,7 +841,7 @@ class _BaseTestApi(object):
repo_name = u'api-repo'
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,
)
response = api_call(self, params)
@@ -857,7 +857,7 @@ class _BaseTestApi(object):
self._compare_ok(id_, expected, given=response.body)
fixture.destroy_repo(repo_name)
- @parametrize('repo_name', [
+ @base.parametrize('repo_name', [
u'',
u'.',
u'..',
@@ -868,7 +868,7 @@ class _BaseTestApi(object):
def test_api_create_repo_bad_names(self, repo_name):
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,
)
response = api_call(self, params)
@@ -883,11 +883,11 @@ class _BaseTestApi(object):
def test_api_create_repo_clone_uri_local(self):
# cloning from local repos was a mis-feature - it would bypass access control
# TODO: introduce other test coverage of actual remote cloning
- clone_uri = os.path.join(TESTS_TMP_PATH, self.REPO)
+ clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO)
repo_name = u'api-repo'
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,
clone_uri=clone_uri,
)
@@ -903,7 +903,7 @@ class _BaseTestApi(object):
# repo creation can no longer also create repo group
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,)
response = api_call(self, params)
expected = u'repo group `%s` not found' % repo_group_name
@@ -916,7 +916,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,)
response = api_call(self, params)
expected = {
@@ -1036,7 +1036,7 @@ class _BaseTestApi(object):
repo_name = self.REPO
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,)
response = api_call(self, params)
expected = "repo `%s` already exist" % repo_name
@@ -1048,7 +1048,7 @@ class _BaseTestApi(object):
repo_name = '%s/%s' % (group_name, 'could-be-outside')
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,)
response = api_call(self, params)
expected = u'repo group `%s` not found' % group_name
@@ -1060,14 +1060,14 @@ class _BaseTestApi(object):
repo_name = u'api-repo'
id_, params = _build_data(self.apikey, 'create_repo',
repo_name=repo_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
repo_type=self.REPO_TYPE,)
response = api_call(self, params)
expected = 'failed to create repository `%s`' % repo_name
self._compare_error(id_, expected, given=response.body)
- @parametrize('changing_attr,updates', [
- ('owner', {'owner': TEST_USER_REGULAR_LOGIN}),
+ @base.parametrize('changing_attr,updates', [
+ ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
('description', {'description': u'new description'}),
('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail
('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control
@@ -1106,8 +1106,8 @@ class _BaseTestApi(object):
if changing_attr == 'repo_group':
fixture.destroy_repo_group(updates['group'])
- @parametrize('changing_attr,updates', [
- ('owner', {'owner': TEST_USER_REGULAR_LOGIN}),
+ @base.parametrize('changing_attr,updates', [
+ ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
('description', {'description': u'new description'}),
('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail
('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control
@@ -1180,7 +1180,7 @@ class _BaseTestApi(object):
repo_name = u'api_update_me'
fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
id_, params = _build_data(self.apikey, 'update_repo',
- repoid=repo_name, owner=TEST_USER_ADMIN_LOGIN,)
+ repoid=repo_name, owner=base.TEST_USER_ADMIN_LOGIN,)
response = api_call(self, params)
try:
expected = 'failed to update repo `%s`' % repo_name
@@ -1237,7 +1237,7 @@ class _BaseTestApi(object):
RepoModel().grant_user_permission(repo=repo_name,
user=self.TEST_USER_LOGIN,
perm='repository.admin')
- updates = {'owner': TEST_USER_ADMIN_LOGIN}
+ updates = {'owner': base.TEST_USER_ADMIN_LOGIN}
id_, params = _build_data(self.apikey_regular, 'update_repo',
repoid=repo_name, **updates)
response = api_call(self, params)
@@ -1314,7 +1314,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'fork_repo',
repoid=self.REPO,
fork_name=fork_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
)
response = api_call(self, params)
@@ -1328,7 +1328,7 @@ class _BaseTestApi(object):
self._compare_ok(id_, expected, given=response.body)
fixture.destroy_repo(fork_name)
- @parametrize('fork_name', [
+ @base.parametrize('fork_name', [
u'api-repo-fork',
u'%s/api-repo-fork' % TEST_REPO_GROUP,
])
@@ -1354,7 +1354,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey_regular, 'fork_repo',
repoid=self.REPO,
fork_name=fork_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
)
response = api_call(self, params)
expected = 'Only Kallithea admin can specify `owner` param'
@@ -1380,7 +1380,7 @@ class _BaseTestApi(object):
perm='repository.read')
fixture.destroy_repo(fork_name)
- @parametrize('name,perm', [
+ @base.parametrize('name,perm', [
('read', 'repository.read'),
('write', 'repository.write'),
('admin', 'repository.admin'),
@@ -1425,7 +1425,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'fork_repo',
repoid=self.REPO,
fork_name=fork_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
)
response = api_call(self, params)
@@ -1440,7 +1440,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'fork_repo',
repoid=self.REPO,
fork_name=fork_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
)
response = api_call(self, params)
@@ -1453,7 +1453,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey, 'fork_repo',
repoid=self.REPO,
fork_name=fork_name,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
)
response = api_call(self, params)
@@ -1529,10 +1529,10 @@ class _BaseTestApi(object):
expected = 'failed to create group `%s`' % group_name
self._compare_error(id_, expected, given=response.body)
- @parametrize('changing_attr,updates', [
+ @base.parametrize('changing_attr,updates', [
('group_name', {'group_name': u'new_group_name'}),
('group_name', {'group_name': u'test_group_for_update'}),
- ('owner', {'owner': TEST_USER_REGULAR_LOGIN}),
+ ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
('active', {'active': False}),
('active', {'active': True}),
])
@@ -1574,11 +1574,11 @@ class _BaseTestApi(object):
try:
id_, params = _build_data(self.apikey, 'add_user_to_user_group',
usergroupid=gr_name,
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = {
'msg': 'added member `%s` to user group `%s`' % (
- TEST_USER_ADMIN_LOGIN, gr_name),
+ base.TEST_USER_ADMIN_LOGIN, gr_name),
'success': True
}
self._compare_ok(id_, expected, given=response.body)
@@ -1588,7 +1588,7 @@ class _BaseTestApi(object):
def test_api_add_user_to_user_group_that_doesnt_exist(self):
id_, params = _build_data(self.apikey, 'add_user_to_user_group',
usergroupid='false-group',
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = 'user group `%s` does not exist' % 'false-group'
@@ -1601,7 +1601,7 @@ class _BaseTestApi(object):
try:
id_, params = _build_data(self.apikey, 'add_user_to_user_group',
usergroupid=gr_name,
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = 'failed to add member to user group `%s`' % gr_name
self._compare_error(id_, expected, given=response.body)
@@ -1611,16 +1611,16 @@ class _BaseTestApi(object):
def test_api_remove_user_from_user_group(self):
gr_name = u'test_group_3'
gr = fixture.create_user_group(gr_name)
- UserGroupModel().add_user_to_group(gr, user=TEST_USER_ADMIN_LOGIN)
+ UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
try:
id_, params = _build_data(self.apikey, 'remove_user_from_user_group',
usergroupid=gr_name,
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = {
'msg': 'removed member `%s` from user group `%s`' % (
- TEST_USER_ADMIN_LOGIN, gr_name
+ base.TEST_USER_ADMIN_LOGIN, gr_name
),
'success': True}
self._compare_ok(id_, expected, given=response.body)
@@ -1631,12 +1631,12 @@ class _BaseTestApi(object):
def test_api_remove_user_from_user_group_exception_occurred(self):
gr_name = u'test_group_3'
gr = fixture.create_user_group(gr_name)
- UserGroupModel().add_user_to_group(gr, user=TEST_USER_ADMIN_LOGIN)
+ UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
try:
id_, params = _build_data(self.apikey, 'remove_user_from_user_group',
usergroupid=gr_name,
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = 'failed to remove member from user group `%s`' % gr_name
self._compare_error(id_, expected, given=response.body)
@@ -1693,7 +1693,7 @@ class _BaseTestApi(object):
finally:
fixture.destroy_user_group(gr_name)
- @parametrize('name,perm', [
+ @base.parametrize('name,perm', [
('none', 'repository.none'),
('read', 'repository.read'),
('write', 'repository.write'),
@@ -1703,13 +1703,13 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission',
repoid=self.REPO,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm)
response = api_call(self, params)
ret = {
'msg': 'Granted perm: `%s` for user: `%s` in repo: `%s`' % (
- perm, TEST_USER_ADMIN_LOGIN, self.REPO
+ perm, base.TEST_USER_ADMIN_LOGIN, self.REPO
),
'success': True
}
@@ -1721,7 +1721,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission',
repoid=self.REPO,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm)
response = api_call(self, params)
@@ -1734,12 +1734,12 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission',
repoid=self.REPO,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm)
response = api_call(self, params)
expected = 'failed to edit permission for user: `%s` in repo: `%s`' % (
- TEST_USER_ADMIN_LOGIN, self.REPO
+ base.TEST_USER_ADMIN_LOGIN, self.REPO
)
self._compare_error(id_, expected, given=response.body)
@@ -1747,12 +1747,12 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'revoke_user_permission',
repoid=self.REPO,
- userid=TEST_USER_ADMIN_LOGIN, )
+ userid=base.TEST_USER_ADMIN_LOGIN, )
response = api_call(self, params)
expected = {
'msg': 'Revoked perm for user: `%s` in repo: `%s`' % (
- TEST_USER_ADMIN_LOGIN, self.REPO
+ base.TEST_USER_ADMIN_LOGIN, self.REPO
),
'success': True
}
@@ -1763,15 +1763,15 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'revoke_user_permission',
repoid=self.REPO,
- userid=TEST_USER_ADMIN_LOGIN, )
+ userid=base.TEST_USER_ADMIN_LOGIN, )
response = api_call(self, params)
expected = 'failed to edit permission for user: `%s` in repo: `%s`' % (
- TEST_USER_ADMIN_LOGIN, self.REPO
+ base.TEST_USER_ADMIN_LOGIN, self.REPO
)
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,perm', [
+ @base.parametrize('name,perm', [
('none', 'repository.none'),
('read', 'repository.read'),
('write', 'repository.write'),
@@ -1853,7 +1853,7 @@ class _BaseTestApi(object):
)
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,perm,apply_to_children', [
+ @base.parametrize('name,perm,apply_to_children', [
('none', 'group.none', 'none'),
('read', 'group.read', 'none'),
('write', 'group.write', 'none'),
@@ -1878,20 +1878,20 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission_to_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm, apply_to_children=apply_to_children)
response = api_call(self, params)
ret = {
'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % (
- perm, apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ perm, apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
),
'success': True
}
expected = ret
self._compare_ok(id_, expected, given=response.body)
- @parametrize('name,perm,apply_to_children,grant_admin,access_ok', [
+ @base.parametrize('name,perm,apply_to_children,grant_admin,access_ok', [
('none_fails', 'group.none', 'none', False, False),
('read_fails', 'group.read', 'none', False, False),
('write_fails', 'group.write', 'none', False, False),
@@ -1914,13 +1914,13 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey_regular,
'grant_user_permission_to_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm, apply_to_children=apply_to_children)
response = api_call(self, params)
if access_ok:
ret = {
'msg': 'Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % (
- perm, apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ perm, apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
),
'success': True
}
@@ -1935,7 +1935,7 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission_to_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm)
response = api_call(self, params)
@@ -1948,16 +1948,16 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'grant_user_permission_to_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
perm=perm)
response = api_call(self, params)
expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % (
- TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
)
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,apply_to_children', [
+ @base.parametrize('name,apply_to_children', [
('none', 'none'),
('all', 'all'),
('repos', 'repos'),
@@ -1965,26 +1965,26 @@ class _BaseTestApi(object):
])
def test_api_revoke_user_permission_from_repo_group(self, name, apply_to_children):
RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP,
- user=TEST_USER_ADMIN_LOGIN,
+ user=base.TEST_USER_ADMIN_LOGIN,
perm='group.read',)
Session().commit()
id_, params = _build_data(self.apikey,
'revoke_user_permission_from_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
apply_to_children=apply_to_children,)
response = api_call(self, params)
expected = {
'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % (
- apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
),
'success': True
}
self._compare_ok(id_, expected, given=response.body)
- @parametrize('name,apply_to_children,grant_admin,access_ok', [
+ @base.parametrize('name,apply_to_children,grant_admin,access_ok', [
('none', 'none', False, False),
('all', 'all', False, False),
('repos', 'repos', False, False),
@@ -1999,7 +1999,7 @@ class _BaseTestApi(object):
def test_api_revoke_user_permission_from_repo_group_by_regular_user(
self, name, apply_to_children, grant_admin, access_ok):
RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP,
- user=TEST_USER_ADMIN_LOGIN,
+ user=base.TEST_USER_ADMIN_LOGIN,
perm='group.read',)
Session().commit()
@@ -2012,13 +2012,13 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey_regular,
'revoke_user_permission_from_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN,
+ userid=base.TEST_USER_ADMIN_LOGIN,
apply_to_children=apply_to_children,)
response = api_call(self, params)
if access_ok:
expected = {
'msg': 'Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % (
- apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
),
'success': True
}
@@ -2032,15 +2032,15 @@ class _BaseTestApi(object):
id_, params = _build_data(self.apikey,
'revoke_user_permission_from_repo_group',
repogroupid=TEST_REPO_GROUP,
- userid=TEST_USER_ADMIN_LOGIN, )
+ userid=base.TEST_USER_ADMIN_LOGIN, )
response = api_call(self, params)
expected = 'failed to edit permission for user: `%s` in repo group: `%s`' % (
- TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
)
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,perm,apply_to_children', [
+ @base.parametrize('name,perm,apply_to_children', [
('none', 'group.none', 'none'),
('read', 'group.read', 'none'),
('write', 'group.write', 'none'),
@@ -2079,7 +2079,7 @@ class _BaseTestApi(object):
expected = ret
self._compare_ok(id_, expected, given=response.body)
- @parametrize('name,perm,apply_to_children,grant_admin,access_ok', [
+ @base.parametrize('name,perm,apply_to_children,grant_admin,access_ok', [
('none_fails', 'group.none', 'none', False, False),
('read_fails', 'group.read', 'none', False, False),
('write_fails', 'group.write', 'none', False, False),
@@ -2146,7 +2146,7 @@ class _BaseTestApi(object):
)
self._compare_error(id_, expected, given=response.body)
- @parametrize('name,apply_to_children', [
+ @base.parametrize('name,apply_to_children', [
('none', 'none'),
('all', 'all'),
('repos', 'repos'),
@@ -2172,7 +2172,7 @@ class _BaseTestApi(object):
}
self._compare_ok(id_, expected, given=response.body)
- @parametrize('name,apply_to_children,grant_admin,access_ok', [
+ @base.parametrize('name,apply_to_children,grant_admin,access_ok', [
('none', 'none', False, False),
('all', 'all', False, False),
('repos', 'repos', False, False),
@@ -2187,7 +2187,7 @@ class _BaseTestApi(object):
def test_api_revoke_user_group_permission_from_repo_group_by_regular_user(
self, name, apply_to_children, grant_admin, access_ok):
RepoGroupModel().grant_user_permission(repo_group=TEST_REPO_GROUP,
- user=TEST_USER_ADMIN_LOGIN,
+ user=base.TEST_USER_ADMIN_LOGIN,
perm='group.read',)
Session().commit()
@@ -2206,7 +2206,7 @@ class _BaseTestApi(object):
if access_ok:
expected = {
'msg': 'Revoked perm (recursive:%s) for user group: `%s` in repo group: `%s`' % (
- apply_to_children, TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
+ apply_to_children, base.TEST_USER_ADMIN_LOGIN, TEST_REPO_GROUP
),
'success': True
}
@@ -2310,7 +2310,7 @@ class _BaseTestApi(object):
def test_api_get_gists_regular_user_with_different_userid(self):
id_, params = _build_data(self.apikey_regular, 'get_gists',
- userid=TEST_USER_ADMIN_LOGIN)
+ userid=base.TEST_USER_ADMIN_LOGIN)
response = api_call(self, params)
expected = 'userid is not the same as your user'
self._compare_error(id_, expected, given=response.body)
@@ -2501,10 +2501,10 @@ class _BaseTestApi(object):
"org_repo_url": "http://localhost:80/%s" % self.REPO,
"org_ref_parts": ["branch", "stable", self.TEST_PR_SRC],
"other_ref_parts": ["branch", "default", self.TEST_PR_DST],
- "comments": [{"username": TEST_USER_ADMIN_LOGIN, "text": "",
+ "comments": [{"username": base.TEST_USER_ADMIN_LOGIN, "text": "",
"comment_id": pullrequest.comments[0].comment_id}],
- "owner": TEST_USER_ADMIN_LOGIN,
- "statuses": [{"status": "under_review", "reviewer": TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00"} for i in range(0, len(self.TEST_PR_REVISIONS))],
+ "owner": base.TEST_USER_ADMIN_LOGIN,
+ "statuses": [{"status": "under_review", "reviewer": base.TEST_USER_ADMIN_LOGIN, "modified_at": "2000-01-01T00:00:00"} for i in range(0, len(self.TEST_PR_REVISIONS))],
"title": "get test",
"revisions": self.TEST_PR_REVISIONS,
}
@@ -2534,7 +2534,7 @@ class _BaseTestApi(object):
random_id = random.randrange(1, 9999)
params = json.dumps({
"id": random_id,
- "api_key": User.get_by_username(TEST_USER_REGULAR2_LOGIN).api_key,
+ "api_key": User.get_by_username(base.TEST_USER_REGULAR2_LOGIN).api_key,
"method": "comment_pullrequest",
"args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED},
})
@@ -2544,7 +2544,7 @@ class _BaseTestApi(object):
assert ChangesetStatus.STATUS_UNDER_REVIEW == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2]
params = json.dumps({
"id": random_id,
- "api_key": User.get_by_username(TEST_USER_REGULAR_LOGIN).api_key,
+ "api_key": User.get_by_username(base.TEST_USER_REGULAR_LOGIN).api_key,
"method": "comment_pullrequest",
"args": {"pull_request_id": pull_request_id, "status": ChangesetStatus.STATUS_APPROVED},
})
diff --git a/kallithea/tests/functional/test_admin.py b/kallithea/tests/functional/test_admin.py
--- a/kallithea/tests/functional/test_admin.py
+++ b/kallithea/tests/functional/test_admin.py
@@ -6,13 +6,13 @@ from os.path import dirname
from kallithea.lib.utils2 import safe_unicode
from kallithea.model.db import UserLog
from kallithea.model.meta import Session
-from kallithea.tests.base import *
+from kallithea.tests import base
FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures')
-class TestAdminController(TestController):
+class TestAdminController(base.TestController):
@classmethod
def setup_class(cls):
@@ -52,105 +52,105 @@ class TestAdminController(TestController
def test_index(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index'))
+ response = self.app.get(base.url(controller='admin/admin', action='index'))
response.mustcontain('Admin Journal')
def test_filter_all_entries(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',))
+ response = self.app.get(base.url(controller='admin/admin', action='index',))
response.mustcontain(' 2036 Entries')
def test_filter_journal_filter_exact_match_on_repository(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:xxx'))
response.mustcontain(' 3 Entries')
def test_filter_journal_filter_exact_match_on_repository_CamelCase(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:XxX'))
response.mustcontain(' 3 Entries')
def test_filter_journal_filter_wildcard_on_repository(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:*test*'))
response.mustcontain(' 862 Entries')
def test_filter_journal_filter_prefix_on_repository(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:test*'))
response.mustcontain(' 257 Entries')
def test_filter_journal_filter_prefix_on_repository_CamelCase(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:Test*'))
response.mustcontain(' 257 Entries')
def test_filter_journal_filter_prefix_on_repository_and_user(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:test* AND username:demo'))
response.mustcontain(' 130 Entries')
def test_filter_journal_filter_prefix_on_repository_or_other_repo(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='repository:test* OR repository:xxx'))
response.mustcontain(' 260 Entries') # 257 + 3
def test_filter_journal_filter_exact_match_on_username(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='username:demo'))
response.mustcontain(' 1087 Entries')
def test_filter_journal_filter_exact_match_on_username_camelCase(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='username:DemO'))
response.mustcontain(' 1087 Entries')
def test_filter_journal_filter_wildcard_on_username(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='username:*test*'))
response.mustcontain(' 100 Entries')
def test_filter_journal_filter_prefix_on_username(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='username:demo*'))
response.mustcontain(' 1101 Entries')
def test_filter_journal_filter_prefix_on_user_or_other_user(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='username:demo OR username:volcan'))
response.mustcontain(' 1095 Entries') # 1087 + 8
def test_filter_journal_filter_wildcard_on_action(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='action:*pull_request*'))
response.mustcontain(' 187 Entries')
def test_filter_journal_filter_on_date(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='date:20121010'))
response.mustcontain(' 47 Entries')
def test_filter_journal_filter_on_date_2(self):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter='date:20121020'))
response.mustcontain(' 17 Entries')
- @parametrize('filter,hit', [
+ @base.parametrize('filter,hit', [
#### "repository:" filtering
# "/" is used for grouping
('repository:group/test', 4),
@@ -189,7 +189,7 @@ class TestAdminController(TestController
def test_filter_journal_filter_tokenization(self, filter, hit):
self.log_user()
- response = self.app.get(url(controller='admin/admin', action='index',
+ response = self.app.get(base.url(controller='admin/admin', action='index',
filter=filter))
if hit != 1:
response.mustcontain(' %s Entries' % hit)
diff --git a/kallithea/tests/functional/test_admin_auth_settings.py b/kallithea/tests/functional/test_admin_auth_settings.py
--- a/kallithea/tests/functional/test_admin_auth_settings.py
+++ b/kallithea/tests/functional/test_admin_auth_settings.py
@@ -1,10 +1,10 @@
from kallithea.model.db import Setting
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestAuthSettingsController(TestController):
+class TestAuthSettingsController(base.TestController):
def _enable_plugins(self, plugins_list):
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
params={'auth_plugins': plugins_list, '_session_csrf_secret_token': self.session_csrf_secret_token()}
@@ -17,11 +17,11 @@ class TestAuthSettingsController(TestCon
def test_index(self):
self.log_user()
- response = self.app.get(url(controller='admin/auth_settings',
+ response = self.app.get(base.url(controller='admin/auth_settings',
action='index'))
response.mustcontain('Authentication Plugins')
- @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib')
+ @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib')
def test_ldap_save_settings(self):
self.log_user()
@@ -41,7 +41,7 @@ class TestAuthSettingsController(TestCon
'auth_ldap_attr_lastname': 'tester',
'auth_ldap_attr_email': 'test@example.com'})
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
@@ -50,7 +50,7 @@ class TestAuthSettingsController(TestCon
new_settings = Setting.get_auth_settings()
assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare'
- @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib')
+ @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib')
def test_ldap_error_form_wrong_port_number(self):
self.log_user()
@@ -68,7 +68,7 @@ class TestAuthSettingsController(TestCon
'auth_ldap_attr_firstname': '',
'auth_ldap_attr_lastname': '',
'auth_ldap_attr_email': ''})
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
@@ -76,7 +76,7 @@ class TestAuthSettingsController(TestCon
response.mustcontain(""""""
"""Please enter a number""")
- @skipif(not ldap_lib_installed, reason='skipping due to missing ldap lib')
+ @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib')
def test_ldap_error_form(self):
self.log_user()
@@ -95,7 +95,7 @@ class TestAuthSettingsController(TestCon
'auth_ldap_attr_lastname': '',
'auth_ldap_attr_email': ''})
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
@@ -115,7 +115,7 @@ class TestAuthSettingsController(TestCon
params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_container')
params.update(settings)
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
@@ -124,7 +124,7 @@ class TestAuthSettingsController(TestCon
def _container_auth_verify_login(self, resulting_username, **get_kwargs):
response = self.app.get(
- url=url(controller='admin/my_account', action='my_account'),
+ url=base.url(controller='admin/my_account', action='my_account'),
**get_kwargs
)
response.mustcontain('My Account %s' % resulting_username)
@@ -153,7 +153,7 @@ class TestAuthSettingsController(TestCon
auth_container_clean_username='False',
)
response = self.app.get(
- url=url(controller='admin/my_account', action='my_account'),
+ url=base.url(controller='admin/my_account', action='my_account'),
extra_environ={'THE_USER_NAME': 'johnd',
'THE_USER_EMAIL': 'john@example.org',
'THE_USER_FIRSTNAME': 'John',
@@ -216,7 +216,7 @@ class TestAuthSettingsController(TestCon
auth_container_clean_username='True',
)
response = self.app.get(
- url=url(controller='admin/my_account', action='my_account'),
+ url=base.url(controller='admin/my_account', action='my_account'),
extra_environ={'REMOTE_USER': 'john'},
)
assert b'Log Out' not in response.normal_body
@@ -232,7 +232,7 @@ class TestAuthSettingsController(TestCon
'auth_crowd_method': 'https',
'auth_crowd_app_name': 'xyzzy'})
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
@@ -241,7 +241,7 @@ class TestAuthSettingsController(TestCon
new_settings = Setting.get_auth_settings()
assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare'
- @skipif(not pam_lib_installed, reason='skipping due to missing pam lib')
+ @base.skipif(not base.pam_lib_installed, reason='skipping due to missing pam lib')
def test_pam_save_settings(self):
self.log_user()
@@ -249,7 +249,7 @@ class TestAuthSettingsController(TestCon
params.update({'auth_pam_service': 'kallithea',
'auth_pam_gecos': '^foo-.*'})
- test_url = url(controller='admin/auth_settings',
+ test_url = base.url(controller='admin/auth_settings',
action='auth_settings')
response = self.app.post(url=test_url, params=params)
diff --git a/kallithea/tests/functional/test_admin_defaults.py b/kallithea/tests/functional/test_admin_defaults.py
--- a/kallithea/tests/functional/test_admin_defaults.py
+++ b/kallithea/tests/functional/test_admin_defaults.py
@@ -1,12 +1,12 @@
from kallithea.model.db import Setting
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestDefaultsController(TestController):
+class TestDefaultsController(base.TestController):
def test_index(self):
self.log_user()
- response = self.app.get(url('defaults'))
+ response = self.app.get(base.url('defaults'))
response.mustcontain('default_repo_private')
response.mustcontain('default_repo_enable_statistics')
response.mustcontain('default_repo_enable_downloads')
@@ -20,7 +20,7 @@ class TestDefaultsController(TestControl
'default_repo_type': 'hg',
'_session_csrf_secret_token': self.session_csrf_secret_token(),
}
- response = self.app.post(url('defaults_update', id='default'), params=params)
+ response = self.app.post(base.url('defaults_update', id='default'), params=params)
self.checkSessionFlash(response, 'Default settings updated successfully')
params.pop('_session_csrf_secret_token')
@@ -36,7 +36,7 @@ class TestDefaultsController(TestControl
'default_repo_type': 'git',
'_session_csrf_secret_token': self.session_csrf_secret_token(),
}
- response = self.app.post(url('defaults_update', id='default'), params=params)
+ response = self.app.post(base.url('defaults_update', id='default'), params=params)
self.checkSessionFlash(response, 'Default settings updated successfully')
params.pop('_session_csrf_secret_token')
diff --git a/kallithea/tests/functional/test_admin_gists.py b/kallithea/tests/functional/test_admin_gists.py
--- a/kallithea/tests/functional/test_admin_gists.py
+++ b/kallithea/tests/functional/test_admin_gists.py
@@ -1,24 +1,24 @@
from kallithea.model.db import Gist, User
from kallithea.model.gist import GistModel
from kallithea.model.meta import Session
-from kallithea.tests.base import *
+from kallithea.tests import base
def _create_gist(f_name, content='some gist', lifetime=-1,
description=u'gist-desc', gist_type='public',
- owner=TEST_USER_ADMIN_LOGIN):
+ owner=base.TEST_USER_ADMIN_LOGIN):
gist_mapping = {
f_name: {'content': content}
}
owner = User.get_by_username(owner)
- gist = GistModel().create(description, owner=owner, ip_addr=IP_ADDR,
+ gist = GistModel().create(description, owner=owner, ip_addr=base.IP_ADDR,
gist_mapping=gist_mapping, gist_type=gist_type,
lifetime=lifetime)
Session().commit()
return gist
-class TestGistsController(TestController):
+class TestGistsController(base.TestController):
def teardown_method(self, method):
for g in Gist.query():
@@ -27,7 +27,7 @@ class TestGistsController(TestController
def test_index(self):
self.log_user()
- response = self.app.get(url('gists'))
+ response = self.app.get(base.url('gists'))
# Test response...
response.mustcontain('There are no gists yet')
@@ -35,7 +35,7 @@ class TestGistsController(TestController
g2 = _create_gist('gist2', lifetime=1400).gist_access_id
g3 = _create_gist('gist3', description=u'gist3-desc').gist_access_id
g4 = _create_gist('gist4', gist_type='private').gist_access_id
- response = self.app.get(url('gists'))
+ response = self.app.get(base.url('gists'))
# Test response...
response.mustcontain('gist: %s' % g1)
response.mustcontain('gist: %s' % g2)
@@ -47,7 +47,7 @@ class TestGistsController(TestController
def test_index_private_gists(self):
self.log_user()
gist = _create_gist('gist5', gist_type='private')
- response = self.app.get(url('gists', private=1))
+ response = self.app.get(base.url('gists', private=1))
# Test response...
# and privates
@@ -55,7 +55,7 @@ class TestGistsController(TestController
def test_create_missing_description(self):
self.log_user()
- response = self.app.post(url('gists'),
+ response = self.app.post(base.url('gists'),
params={'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()},
status=200)
@@ -63,7 +63,7 @@ class TestGistsController(TestController
def test_create(self):
self.log_user()
- response = self.app.post(url('gists'),
+ response = self.app.post(base.url('gists'),
params={'lifetime': -1,
'content': 'gist test',
'filename': 'foo',
@@ -77,7 +77,7 @@ class TestGistsController(TestController
def test_create_with_path_with_dirs(self):
self.log_user()
- response = self.app.post(url('gists'),
+ response = self.app.post(base.url('gists'),
params={'lifetime': -1,
'content': 'gist test',
'filename': '/home/foo',
@@ -92,11 +92,11 @@ class TestGistsController(TestController
gist.gist_expires = 0 # 1970
Session().commit()
- response = self.app.get(url('gist', gist_id=gist.gist_access_id), status=404)
+ response = self.app.get(base.url('gist', gist_id=gist.gist_access_id), status=404)
def test_create_private(self):
self.log_user()
- response = self.app.post(url('gists'),
+ response = self.app.post(base.url('gists'),
params={'lifetime': -1,
'content': 'private gist test',
'filename': 'private-foo',
@@ -110,7 +110,7 @@ class TestGistsController(TestController
def test_create_with_description(self):
self.log_user()
- response = self.app.post(url('gists'),
+ response = self.app.post(base.url('gists'),
params={'lifetime': -1,
'content': 'gist test',
'filename': 'foo-desc',
@@ -126,46 +126,46 @@ class TestGistsController(TestController
def test_new(self):
self.log_user()
- response = self.app.get(url('new_gist'))
+ response = self.app.get(base.url('new_gist'))
def test_delete(self):
self.log_user()
gist = _create_gist('delete-me')
- response = self.app.post(url('gist_delete', gist_id=gist.gist_id),
+ response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
def test_delete_normal_user_his_gist(self):
- self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
- gist = _create_gist('delete-me', owner=TEST_USER_REGULAR_LOGIN)
- response = self.app.post(url('gist_delete', gist_id=gist.gist_id),
+ self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
+ gist = _create_gist('delete-me', owner=base.TEST_USER_REGULAR_LOGIN)
+ response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
def test_delete_normal_user_not_his_own_gist(self):
- self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
+ self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
gist = _create_gist('delete-me')
- response = self.app.post(url('gist_delete', gist_id=gist.gist_id), status=403,
+ response = self.app.post(base.url('gist_delete', gist_id=gist.gist_id), status=403,
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
def test_show(self):
gist = _create_gist('gist-show-me')
- response = self.app.get(url('gist', gist_id=gist.gist_access_id))
+ response = self.app.get(base.url('gist', gist_id=gist.gist_access_id))
response.mustcontain('added file: gist-show-me<')
- response.mustcontain('%s - created' % TEST_USER_ADMIN_LOGIN)
+ response.mustcontain('%s - created' % base.TEST_USER_ADMIN_LOGIN)
response.mustcontain('gist-desc')
response.mustcontain('
Public Gist
')
def test_show_as_raw(self):
gist = _create_gist('gist-show-me', content='GIST CONTENT')
- response = self.app.get(url('formatted_gist',
+ response = self.app.get(base.url('formatted_gist',
gist_id=gist.gist_access_id, format='raw'))
assert response.body == b'GIST CONTENT'
def test_show_as_raw_individual_file(self):
gist = _create_gist('gist-show-me-raw', content='GIST BODY')
- response = self.app.get(url('formatted_gist_file',
+ response = self.app.get(base.url('formatted_gist_file',
gist_id=gist.gist_access_id, format='raw',
revision='tip', f_path='gist-show-me-raw'))
assert response.body == b'GIST BODY'
def test_edit(self):
- response = self.app.get(url('edit_gist', gist_id=1))
+ response = self.app.get(base.url('edit_gist', gist_id=1))
diff --git a/kallithea/tests/functional/test_admin_permissions.py b/kallithea/tests/functional/test_admin_permissions.py
--- a/kallithea/tests/functional/test_admin_permissions.py
+++ b/kallithea/tests/functional/test_admin_permissions.py
@@ -1,17 +1,17 @@
from kallithea.model.db import User, UserIpMap
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestAdminPermissionsController(TestController):
+class TestAdminPermissionsController(base.TestController):
def test_index(self):
self.log_user()
- response = self.app.get(url('admin_permissions'))
+ response = self.app.get(base.url('admin_permissions'))
# Test response...
def test_index_ips(self):
self.log_user()
- response = self.app.get(url('admin_permissions_ips'))
+ response = self.app.get(base.url('admin_permissions_ips'))
# Test response...
response.mustcontain('All IP addresses are allowed')
@@ -21,61 +21,61 @@ class TestAdminPermissionsController(Tes
# Add IP and verify it is shown in UI and both gives access and rejects
- response = self.app.post(url('edit_user_ips_update', id=default_user_id),
+ response = self.app.post(base.url('edit_user_ips_update', id=default_user_id),
params=dict(new_ip='0.0.0.0/24',
_session_csrf_secret_token=self.session_csrf_secret_token()))
- invalidate_all_caches()
- response = self.app.get(url('admin_permissions_ips'),
+ base.invalidate_all_caches()
+ response = self.app.get(base.url('admin_permissions_ips'),
extra_environ={'REMOTE_ADDR': '0.0.0.1'})
response.mustcontain('0.0.0.0/24')
response.mustcontain('0.0.0.0 - 0.0.0.255')
- response = self.app.get(url('admin_permissions_ips'),
+ response = self.app.get(base.url('admin_permissions_ips'),
extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403)
# Add another IP and verify previously rejected now works
- response = self.app.post(url('edit_user_ips_update', id=default_user_id),
+ response = self.app.post(base.url('edit_user_ips_update', id=default_user_id),
params=dict(new_ip='0.0.1.0/24',
_session_csrf_secret_token=self.session_csrf_secret_token()))
- invalidate_all_caches()
+ base.invalidate_all_caches()
- response = self.app.get(url('admin_permissions_ips'),
+ response = self.app.get(base.url('admin_permissions_ips'),
extra_environ={'REMOTE_ADDR': '0.0.1.1'})
# Delete latest IP and verify same IP is rejected again
x = UserIpMap.query().filter_by(ip_addr='0.0.1.0/24').first()
- response = self.app.post(url('edit_user_ips_delete', id=default_user_id),
+ response = self.app.post(base.url('edit_user_ips_delete', id=default_user_id),
params=dict(del_ip_id=x.ip_id,
_session_csrf_secret_token=self.session_csrf_secret_token()))
- invalidate_all_caches()
+ base.invalidate_all_caches()
- response = self.app.get(url('admin_permissions_ips'),
+ response = self.app.get(base.url('admin_permissions_ips'),
extra_environ={'REMOTE_ADDR': '0.0.1.1'}, status=403)
# Delete first IP and verify unlimited access again
x = UserIpMap.query().filter_by(ip_addr='0.0.0.0/24').first()
- response = self.app.post(url('edit_user_ips_delete', id=default_user_id),
+ response = self.app.post(base.url('edit_user_ips_delete', id=default_user_id),
params=dict(del_ip_id=x.ip_id,
_session_csrf_secret_token=self.session_csrf_secret_token()))
- invalidate_all_caches()
+ base.invalidate_all_caches()
- response = self.app.get(url('admin_permissions_ips'),
+ response = self.app.get(base.url('admin_permissions_ips'),
extra_environ={'REMOTE_ADDR': '0.0.1.1'})
def test_index_overview(self):
self.log_user()
- response = self.app.get(url('admin_permissions_perms'))
+ response = self.app.get(base.url('admin_permissions_perms'))
# Test response...
def test_edit_permissions_permissions(self):
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
# Test unauthenticated access - it will redirect to login page
response = self.app.post(
- url('edit_repo_perms_update', repo_name=HG_REPO),
+ base.url('edit_repo_perms_update', repo_name=base.HG_REPO),
params=dict(
perm_new_member_1='repository.read',
perm_new_member_name_1=user.username,
@@ -83,24 +83,24 @@ class TestAdminPermissionsController(Tes
_session_csrf_secret_token=self.session_csrf_secret_token()),
status=302)
- assert not response.location.endswith(url('edit_repo_perms_update', repo_name=HG_REPO))
- assert response.location.endswith(url('login_home', came_from=url('edit_repo_perms_update', repo_name=HG_REPO)))
+ assert not response.location.endswith(base.url('edit_repo_perms_update', repo_name=base.HG_REPO))
+ assert response.location.endswith(base.url('login_home', came_from=base.url('edit_repo_perms_update', repo_name=base.HG_REPO)))
response = self.app.post(
- url('edit_repo_perms_revoke', repo_name=HG_REPO),
+ base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO),
params=dict(
obj_type='user',
user_id=user.user_id,
_session_csrf_secret_token=self.session_csrf_secret_token()),
status=302)
- assert response.location.endswith(url('login_home', came_from=url('edit_repo_perms_revoke', repo_name=HG_REPO)))
+ assert response.location.endswith(base.url('login_home', came_from=base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO)))
# Test authenticated access
self.log_user()
response = self.app.post(
- url('edit_repo_perms_update', repo_name=HG_REPO),
+ base.url('edit_repo_perms_update', repo_name=base.HG_REPO),
params=dict(
perm_new_member_1='repository.read',
perm_new_member_name_1=user.username,
@@ -108,10 +108,10 @@ class TestAdminPermissionsController(Tes
_session_csrf_secret_token=self.session_csrf_secret_token()),
status=302)
- assert response.location.endswith(url('edit_repo_perms_update', repo_name=HG_REPO))
+ assert response.location.endswith(base.url('edit_repo_perms_update', repo_name=base.HG_REPO))
response = self.app.post(
- url('edit_repo_perms_revoke', repo_name=HG_REPO),
+ base.url('edit_repo_perms_revoke', repo_name=base.HG_REPO),
params=dict(
obj_type='user',
user_id=user.user_id,
diff --git a/kallithea/tests/functional/test_admin_repos.py b/kallithea/tests/functional/test_admin_repos.py
--- a/kallithea/tests/functional/test_admin_repos.py
+++ b/kallithea/tests/functional/test_admin_repos.py
@@ -13,7 +13,7 @@ from kallithea.model.meta import Session
from kallithea.model.repo import RepoModel
from kallithea.model.repo_group import RepoGroupModel
from kallithea.model.user import UserModel
-from kallithea.tests.base import *
+from kallithea.tests import base
from kallithea.tests.fixture import Fixture, error_function
@@ -29,7 +29,7 @@ def _get_permission_for_user(user, repo)
return perm
-class _BaseTestCase(TestController):
+class _BaseTestCase(base.TestController):
"""
Write all tests here
"""
@@ -41,20 +41,20 @@ class _BaseTestCase(TestController):
def test_index(self):
self.log_user()
- response = self.app.get(url('repos'))
+ response = self.app.get(base.url('repos'))
def test_create(self):
self.log_user()
repo_name = self.NEW_REPO
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
_session_csrf_secret_token=self.session_csrf_secret_token()))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name))
assert response.json == {u'result': True}
self.checkSessionFlash(response,
'Created repository %s'
@@ -68,7 +68,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name))
response.mustcontain(repo_name)
response.mustcontain(self.REPO_TYPE)
@@ -85,7 +85,7 @@ class _BaseTestCase(TestController):
self.log_user()
repo_name = self.NEW_REPO
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -93,7 +93,7 @@ class _BaseTestCase(TestController):
_session_csrf_secret_token=self.session_csrf_secret_token()))
# try to create repo with swapped case
swapped_repo_name = repo_name.swapcase()
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=swapped_repo_name,
repo_type=self.REPO_TYPE,
@@ -111,13 +111,13 @@ class _BaseTestCase(TestController):
group_name = u'sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description=u'test',
- owner=TEST_USER_ADMIN_LOGIN)
+ owner=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
repo_name = u'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -125,7 +125,7 @@ class _BaseTestCase(TestController):
repo_group=gr.group_id,
_session_csrf_secret_token=self.session_csrf_secret_token()))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full))
assert response.json == {u'result': True}
self.checkSessionFlash(response,
'Created repository %s'
@@ -139,7 +139,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
@@ -160,7 +160,7 @@ class _BaseTestCase(TestController):
Session().commit()
def test_create_in_group_without_needed_permissions(self):
- usr = self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
+ usr = self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
# avoid spurious RepoGroup DetachedInstanceError ...
session_csrf_secret_token = self.session_csrf_secret_token()
# revoke
@@ -172,29 +172,29 @@ class _BaseTestCase(TestController):
user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none')
# disable on regular user
- user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
- user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none')
- user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
- user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
+ user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
+ user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.none')
+ user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
+ user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
Session().commit()
## create GROUP
group_name = u'reg_sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description=u'test',
- owner=TEST_USER_ADMIN_LOGIN)
+ owner=base.TEST_USER_ADMIN_LOGIN)
Session().commit()
group_name_allowed = u'reg_sometest_allowed_%s' % self.REPO_TYPE
gr_allowed = RepoGroupModel().create(group_name=group_name_allowed,
group_description=u'test',
- owner=TEST_USER_REGULAR_LOGIN)
+ owner=base.TEST_USER_REGULAR_LOGIN)
Session().commit()
repo_name = u'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -208,7 +208,7 @@ class _BaseTestCase(TestController):
repo_name = u'ingroup'
repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name])
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -217,7 +217,7 @@ class _BaseTestCase(TestController):
_session_csrf_secret_token=session_csrf_secret_token))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full))
assert response.json == {u'result': True}
self.checkSessionFlash(response,
'Created repository %s'
@@ -231,7 +231,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
@@ -259,9 +259,9 @@ class _BaseTestCase(TestController):
group_name = u'sometest_%s' % self.REPO_TYPE
gr = RepoGroupModel().create(group_name=group_name,
group_description=u'test',
- owner=TEST_USER_ADMIN_LOGIN)
+ owner=base.TEST_USER_ADMIN_LOGIN)
perm = Permission.get_by_key('repository.write')
- RepoGroupModel().grant_user_permission(gr, TEST_USER_REGULAR_LOGIN, perm)
+ RepoGroupModel().grant_user_permission(gr, base.TEST_USER_REGULAR_LOGIN, perm)
## add repo permissions
Session().commit()
@@ -269,7 +269,7 @@ class _BaseTestCase(TestController):
repo_name = u'ingroup_inherited_%s' % self.REPO_TYPE
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -279,7 +279,7 @@ class _BaseTestCase(TestController):
_session_csrf_secret_token=self.session_csrf_secret_token()))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full))
self.checkSessionFlash(response,
'Created repository %s'
% (repo_name_full, repo_name_full))
@@ -292,7 +292,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name_full))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name_full))
response.mustcontain(repo_name_full)
response.mustcontain(self.REPO_TYPE)
@@ -309,7 +309,7 @@ class _BaseTestCase(TestController):
.filter(UserRepoToPerm.repository_id == new_repo_id).all()
assert len(inherited_perms) == 2
- assert TEST_USER_REGULAR_LOGIN in [x.user.username
+ assert base.TEST_USER_REGULAR_LOGIN in [x.user.username
for x in inherited_perms]
assert 'repository.write' in [x.permission.permission_name
for x in inherited_perms]
@@ -322,7 +322,7 @@ class _BaseTestCase(TestController):
self.log_user()
repo_name = self.NEW_REPO
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -335,7 +335,7 @@ class _BaseTestCase(TestController):
self.log_user()
repo_name = self.NEW_REPO
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -348,14 +348,14 @@ class _BaseTestCase(TestController):
self.log_user()
repo_name = u'vcs_test_new_to_delete_%s' % self.REPO_TYPE
description = u'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_type=self.REPO_TYPE,
repo_name=repo_name,
repo_description=description,
_session_csrf_secret_token=self.session_csrf_secret_token()))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name))
self.checkSessionFlash(response,
'Created repository %s'
% (repo_name, repo_name))
@@ -367,7 +367,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name))
response.mustcontain(repo_name)
response.mustcontain(self.REPO_TYPE)
@@ -377,7 +377,7 @@ class _BaseTestCase(TestController):
except vcs.exceptions.VCSError:
pytest.fail('no repo %s in filesystem' % repo_name)
- response = self.app.post(url('delete_repo', repo_name=repo_name),
+ response = self.app.post(base.url('delete_repo', repo_name=repo_name),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name))
@@ -399,14 +399,14 @@ class _BaseTestCase(TestController):
repo_name_unicode = safe_unicode(repo_name)
description = 'description for newly created repo' + non_ascii
description_unicode = safe_unicode(description)
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
repo_description=description,
_session_csrf_secret_token=self.session_csrf_secret_token()))
## run the check page that triggers the flash message
- response = self.app.get(url('repo_check_home', repo_name=repo_name))
+ response = self.app.get(base.url('repo_check_home', repo_name=repo_name))
assert response.json == {u'result': True}
self.checkSessionFlash(response,
u'Created repository %s'
@@ -419,7 +419,7 @@ class _BaseTestCase(TestController):
assert new_repo.description == description_unicode
# test if the repository is visible in the list ?
- response = self.app.get(url('summary_home', repo_name=repo_name))
+ response = self.app.get(base.url('summary_home', repo_name=repo_name))
response.mustcontain(repo_name)
response.mustcontain(self.REPO_TYPE)
@@ -429,7 +429,7 @@ class _BaseTestCase(TestController):
except vcs.exceptions.VCSError:
pytest.fail('no repo %s in filesystem' % repo_name)
- response = self.app.post(url('delete_repo', repo_name=repo_name),
+ response = self.app.post(base.url('delete_repo', repo_name=repo_name),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name_unicode))
response.follow()
@@ -447,15 +447,15 @@ class _BaseTestCase(TestController):
pass
def test_delete_browser_fakeout(self):
- response = self.app.post(url('delete_repo', repo_name=self.REPO),
+ response = self.app.post(base.url('delete_repo', repo_name=self.REPO),
params=dict(_session_csrf_secret_token=self.session_csrf_secret_token()))
def test_show(self):
self.log_user()
- response = self.app.get(url('summary_home', repo_name=self.REPO))
+ response = self.app.get(base.url('summary_home', repo_name=self.REPO))
def test_edit(self):
- response = self.app.get(url('edit_repo', repo_name=self.REPO))
+ response = self.app.get(base.url('edit_repo', repo_name=self.REPO))
def test_set_private_flag_sets_default_to_none(self):
self.log_user()
@@ -465,11 +465,11 @@ class _BaseTestCase(TestController):
assert perm[0].permission.permission_name == 'repository.read'
assert Repository.get_by_repo_name(self.REPO).private == False
- response = self.app.post(url('update_repo', repo_name=self.REPO),
+ response = self.app.post(base.url('update_repo', repo_name=self.REPO),
fixture._get_repo_create_params(repo_private=1,
repo_name=self.REPO,
repo_type=self.REPO_TYPE,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
_session_csrf_secret_token=self.session_csrf_secret_token()))
self.checkSessionFlash(response,
msg='Repository %s updated successfully' % (self.REPO))
@@ -480,11 +480,11 @@ class _BaseTestCase(TestController):
assert len(perm), 1
assert perm[0].permission.permission_name == 'repository.none'
- response = self.app.post(url('update_repo', repo_name=self.REPO),
+ response = self.app.post(base.url('update_repo', repo_name=self.REPO),
fixture._get_repo_create_params(repo_private=False,
repo_name=self.REPO,
repo_type=self.REPO_TYPE,
- owner=TEST_USER_ADMIN_LOGIN,
+ owner=base.TEST_USER_ADMIN_LOGIN,
_session_csrf_secret_token=self.session_csrf_secret_token()))
self.checkSessionFlash(response,
msg='Repository %s updated successfully' % (self.REPO))
@@ -502,7 +502,7 @@ class _BaseTestCase(TestController):
def test_set_repo_fork_has_no_self_id(self):
self.log_user()
repo = Repository.get_by_repo_name(self.REPO)
- response = self.app.get(url('edit_repo_advanced', repo_name=self.REPO))
+ response = self.app.get(base.url('edit_repo_advanced', repo_name=self.REPO))
opt = """""" % (repo.repo_id, self.REPO)
response.mustcontain(no=[opt])
@@ -512,7 +512,7 @@ class _BaseTestCase(TestController):
fixture.create_repo(other_repo, repo_type=self.REPO_TYPE)
repo = Repository.get_by_repo_name(self.REPO)
repo2 = Repository.get_by_repo_name(other_repo)
- response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO),
+ response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO),
params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
repo = Repository.get_by_repo_name(self.REPO)
repo2 = Repository.get_by_repo_name(other_repo)
@@ -533,7 +533,7 @@ class _BaseTestCase(TestController):
self.log_user()
repo = Repository.get_by_repo_name(self.REPO)
repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO)
- response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO),
+ response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO),
params=dict(id_fork_of=repo2.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
repo = Repository.get_by_repo_name(self.REPO)
repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO)
@@ -543,7 +543,7 @@ class _BaseTestCase(TestController):
def test_set_fork_of_none(self):
self.log_user()
## mark it as None
- response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO),
+ response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO),
params=dict(id_fork_of=None, _session_csrf_secret_token=self.session_csrf_secret_token()))
repo = Repository.get_by_repo_name(self.REPO)
repo2 = Repository.get_by_repo_name(self.OTHER_TYPE_REPO)
@@ -555,13 +555,13 @@ class _BaseTestCase(TestController):
def test_set_fork_of_same_repo(self):
self.log_user()
repo = Repository.get_by_repo_name(self.REPO)
- response = self.app.post(url('edit_repo_advanced_fork', repo_name=self.REPO),
+ response = self.app.post(base.url('edit_repo_advanced_fork', repo_name=self.REPO),
params=dict(id_fork_of=repo.repo_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
self.checkSessionFlash(response,
'An error occurred during this operation')
def test_create_on_top_level_without_permissions(self):
- usr = self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
+ usr = self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
# revoke
user_model = UserModel()
# disable fork and create on default user
@@ -571,10 +571,10 @@ class _BaseTestCase(TestController):
user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none')
# disable on regular user
- user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
- user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none')
- user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
- user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
+ user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
+ user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.create.none')
+ user_model.revoke_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
+ user_model.grant_perm(base.TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
Session().commit()
@@ -582,7 +582,7 @@ class _BaseTestCase(TestController):
repo_name = self.NEW_REPO + u'no_perms'
description = 'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -600,7 +600,7 @@ class _BaseTestCase(TestController):
repo_name = self.NEW_REPO
description = 'description for newly created repo'
- response = self.app.post(url('repos'),
+ response = self.app.post(base.url('repos'),
fixture._get_repo_create_params(repo_private=False,
repo_name=repo_name,
repo_type=self.REPO_TYPE,
@@ -618,18 +618,18 @@ class _BaseTestCase(TestController):
class TestAdminReposControllerGIT(_BaseTestCase):
- REPO = GIT_REPO
+ REPO = base.GIT_REPO
REPO_TYPE = 'git'
- NEW_REPO = NEW_GIT_REPO
- OTHER_TYPE_REPO = HG_REPO
+ NEW_REPO = base.NEW_GIT_REPO
+ OTHER_TYPE_REPO = base.HG_REPO
OTHER_TYPE = 'hg'
class TestAdminReposControllerHG(_BaseTestCase):
- REPO = HG_REPO
+ REPO = base.HG_REPO
REPO_TYPE = 'hg'
- NEW_REPO = NEW_HG_REPO
- OTHER_TYPE_REPO = GIT_REPO
+ NEW_REPO = base.NEW_HG_REPO
+ OTHER_TYPE_REPO = base.GIT_REPO
OTHER_TYPE = 'git'
def test_permanent_url_protocol_access(self):
@@ -637,7 +637,7 @@ class TestAdminReposControllerHG(_BaseTe
permanent_name = '_%d' % repo.repo_id
# 400 Bad Request - Unable to detect pull/push action
- self.app.get(url('summary_home', repo_name=permanent_name),
+ self.app.get(base.url('summary_home', repo_name=permanent_name),
extra_environ={'HTTP_ACCEPT': 'application/mercurial'},
status=400,
)
diff --git a/kallithea/tests/functional/test_admin_settings.py b/kallithea/tests/functional/test_admin_settings.py
--- a/kallithea/tests/functional/test_admin_settings.py
+++ b/kallithea/tests/functional/test_admin_settings.py
@@ -1,54 +1,54 @@
# -*- coding: utf-8 -*-
from kallithea.model.db import Setting, Ui
-from kallithea.tests.base import *
+from kallithea.tests import base
from kallithea.tests.fixture import Fixture
fixture = Fixture()
-class TestAdminSettingsController(TestController):
+class TestAdminSettingsController(base.TestController):
def test_index_main(self):
self.log_user()
- response = self.app.get(url('admin_settings'))
+ response = self.app.get(base.url('admin_settings'))
def test_index_mapping(self):
self.log_user()
- response = self.app.get(url('admin_settings_mapping'))
+ response = self.app.get(base.url('admin_settings_mapping'))
def test_index_global(self):
self.log_user()
- response = self.app.get(url('admin_settings_global'))
+ response = self.app.get(base.url('admin_settings_global'))
def test_index_visual(self):
self.log_user()
- response = self.app.get(url('admin_settings_visual'))
+ response = self.app.get(base.url('admin_settings_visual'))
def test_index_email(self):
self.log_user()
- response = self.app.get(url('admin_settings_email'))
+ response = self.app.get(base.url('admin_settings_email'))
def test_index_hooks(self):
self.log_user()
- response = self.app.get(url('admin_settings_hooks'))
+ response = self.app.get(base.url('admin_settings_hooks'))
def test_create_custom_hook(self):
self.log_user()
- response = self.app.post(url('admin_settings_hooks'),
+ response = self.app.post(base.url('admin_settings_hooks'),
params=dict(new_hook_ui_key='test_hooks_1',
- new_hook_ui_value='cd %s' % TESTS_TMP_PATH,
+ new_hook_ui_value='cd %s' % base.TESTS_TMP_PATH,
_session_csrf_secret_token=self.session_csrf_secret_token()))
self.checkSessionFlash(response, 'Added new hook')
response = response.follow()
response.mustcontain('test_hooks_1')
- response.mustcontain('cd %s' % TESTS_TMP_PATH)
+ response.mustcontain('cd %s' % base.TESTS_TMP_PATH)
def test_edit_custom_hook(self):
self.log_user()
- response = self.app.post(url('admin_settings_hooks'),
+ response = self.app.post(base.url('admin_settings_hooks'),
params=dict(hook_ui_key='test_hooks_1',
hook_ui_value='old_value_of_hook_1',
hook_ui_value_new='new_value_of_hook_1',
@@ -60,7 +60,7 @@ class TestAdminSettingsController(TestCo
def test_add_existing_custom_hook(self):
self.log_user()
- response = self.app.post(url('admin_settings_hooks'),
+ response = self.app.post(base.url('admin_settings_hooks'),
params=dict(new_hook_ui_key='test_hooks_1',
new_hook_ui_value='attempted_new_value',
_session_csrf_secret_token=self.session_csrf_secret_token()))
@@ -72,27 +72,27 @@ class TestAdminSettingsController(TestCo
def test_create_custom_hook_delete(self):
self.log_user()
- response = self.app.post(url('admin_settings_hooks'),
+ response = self.app.post(base.url('admin_settings_hooks'),
params=dict(new_hook_ui_key='test_hooks_2',
- new_hook_ui_value='cd %s2' % TESTS_TMP_PATH,
+ new_hook_ui_value='cd %s2' % base.TESTS_TMP_PATH,
_session_csrf_secret_token=self.session_csrf_secret_token()))
self.checkSessionFlash(response, 'Added new hook')
response = response.follow()
response.mustcontain('test_hooks_2')
- response.mustcontain('cd %s2' % TESTS_TMP_PATH)
+ response.mustcontain('cd %s2' % base.TESTS_TMP_PATH)
hook_id = Ui.get_by_key('hooks', 'test_hooks_2').ui_id
## delete
- self.app.post(url('admin_settings_hooks'),
+ self.app.post(base.url('admin_settings_hooks'),
params=dict(hook_id=hook_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
- response = self.app.get(url('admin_settings_hooks'))
+ response = self.app.get(base.url('admin_settings_hooks'))
response.mustcontain(no=['test_hooks_2'])
- response.mustcontain(no=['cd %s2' % TESTS_TMP_PATH])
+ response.mustcontain(no=['cd %s2' % base.TESTS_TMP_PATH])
def test_add_existing_builtin_hook(self):
self.log_user()
- response = self.app.post(url('admin_settings_hooks'),
+ response = self.app.post(base.url('admin_settings_hooks'),
params=dict(new_hook_ui_key='changegroup.update',
new_hook_ui_value='attempted_new_value',
_session_csrf_secret_token=self.session_csrf_secret_token()))
@@ -104,18 +104,18 @@ class TestAdminSettingsController(TestCo
def test_index_search(self):
self.log_user()
- response = self.app.get(url('admin_settings_search'))
+ response = self.app.get(base.url('admin_settings_search'))
def test_index_system(self):
self.log_user()
- response = self.app.get(url('admin_settings_system'))
+ response = self.app.get(base.url('admin_settings_system'))
def test_ga_code_active(self):
self.log_user()
old_title = 'Kallithea'
old_realm = 'Kallithea authentication'
new_ga_code = 'ga-test-123456789'
- response = self.app.post(url('admin_settings_global'),
+ response = self.app.post(base.url('admin_settings_global'),
params=dict(title=old_title,
realm=old_realm,
ga_code=new_ga_code,
@@ -136,7 +136,7 @@ class TestAdminSettingsController(TestCo
old_title = 'Kallithea'
old_realm = 'Kallithea authentication'
new_ga_code = ''
- response = self.app.post(url('admin_settings_global'),
+ response = self.app.post(base.url('admin_settings_global'),
params=dict(title=old_title,
realm=old_realm,
ga_code=new_ga_code,
@@ -156,7 +156,7 @@ class TestAdminSettingsController(TestCo
old_title = 'Kallithea'
old_realm = 'Kallithea authentication'
new_ga_code = ''
- response = self.app.post(url('admin_settings_global'),
+ response = self.app.post(base.url('admin_settings_global'),
params=dict(title=old_title,
realm=old_realm,
ga_code=new_ga_code,
@@ -168,7 +168,7 @@ class TestAdminSettingsController(TestCo
self.checkSessionFlash(response, 'Updated application settings')
assert Setting.get_app_settings()['captcha_private_key'] == '1234567890'
- response = self.app.get(url('register'))
+ response = self.app.get(base.url('register'))
response.mustcontain('captcha')
def test_captcha_deactivate(self):
@@ -176,7 +176,7 @@ class TestAdminSettingsController(TestCo
old_title = 'Kallithea'
old_realm = 'Kallithea authentication'
new_ga_code = ''
- response = self.app.post(url('admin_settings_global'),
+ response = self.app.post(base.url('admin_settings_global'),
params=dict(title=old_title,
realm=old_realm,
ga_code=new_ga_code,
@@ -188,7 +188,7 @@ class TestAdminSettingsController(TestCo
self.checkSessionFlash(response, 'Updated application settings')
assert Setting.get_app_settings()['captcha_private_key'] == ''
- response = self.app.get(url('register'))
+ response = self.app.get(base.url('register'))
response.mustcontain(no=['captcha'])
def test_title_change(self):
@@ -198,7 +198,7 @@ class TestAdminSettingsController(TestCo
old_realm = 'Kallithea authentication'
for new_title in ['Changed', 'Żółwik', old_title]:
- response = self.app.post(url('admin_settings_global'),
+ response = self.app.post(base.url('admin_settings_global'),
params=dict(title=new_title,
realm=old_realm,
ga_code='',
diff --git a/kallithea/tests/functional/test_admin_user_groups.py b/kallithea/tests/functional/test_admin_user_groups.py
--- a/kallithea/tests/functional/test_admin_user_groups.py
+++ b/kallithea/tests/functional/test_admin_user_groups.py
@@ -1,23 +1,23 @@
# -*- coding: utf-8 -*-
from kallithea.model.db import Permission, UserGroup, UserGroupToPerm
from kallithea.model.meta import Session
-from kallithea.tests.base import *
+from kallithea.tests import base
TEST_USER_GROUP = u'admins_test'
-class TestAdminUsersGroupsController(TestController):
+class TestAdminUsersGroupsController(base.TestController):
def test_index(self):
self.log_user()
- response = self.app.get(url('users_groups'))
+ response = self.app.get(base.url('users_groups'))
# Test response...
def test_create(self):
self.log_user()
users_group_name = TEST_USER_GROUP
- response = self.app.post(url('users_groups'),
+ response = self.app.post(base.url('users_groups'),
{'users_group_name': users_group_name,
'user_group_description': u'DESC',
'active': True,
@@ -30,19 +30,19 @@ class TestAdminUsersGroupsController(Tes
'/edit">%s' % TEST_USER_GROUP)
def test_new(self):
- response = self.app.get(url('new_users_group'))
+ response = self.app.get(base.url('new_users_group'))
def test_update(self):
- response = self.app.post(url('update_users_group', id=1), status=403)
+ response = self.app.post(base.url('update_users_group', id=1), status=403)
def test_update_browser_fakeout(self):
- response = self.app.post(url('update_users_group', id=1),
+ response = self.app.post(base.url('update_users_group', id=1),
params=dict(_session_csrf_secret_token=self.session_csrf_secret_token()))
def test_delete(self):
self.log_user()
users_group_name = TEST_USER_GROUP + 'another'
- response = self.app.post(url('users_groups'),
+ response = self.app.post(base.url('users_groups'),
{'users_group_name': users_group_name,
'user_group_description': u'DESC',
'active': True,
@@ -55,7 +55,7 @@ class TestAdminUsersGroupsController(Tes
gr = Session().query(UserGroup) \
.filter(UserGroup.users_group_name == users_group_name).one()
- response = self.app.post(url('delete_users_group', id=gr.users_group_id),
+ response = self.app.post(base.url('delete_users_group', id=gr.users_group_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
gr = Session().query(UserGroup) \
@@ -66,7 +66,7 @@ class TestAdminUsersGroupsController(Tes
def test_default_perms_enable_repository_read_on_group(self):
self.log_user()
users_group_name = TEST_USER_GROUP + 'another2'
- response = self.app.post(url('users_groups'),
+ response = self.app.post(base.url('users_groups'),
{'users_group_name': users_group_name,
'user_group_description': u'DESC',
'active': True,
@@ -77,7 +77,7 @@ class TestAdminUsersGroupsController(Tes
self.checkSessionFlash(response,
'Created user group ')
## ENABLE REPO CREATE ON A GROUP
- response = self.app.post(url('edit_user_group_default_perms_update',
+ response = self.app.post(base.url('edit_user_group_default_perms_update',
id=ug.users_group_id),
{'create_repo_perm': True,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
@@ -97,7 +97,7 @@ class TestAdminUsersGroupsController(Tes
## DISABLE REPO CREATE ON A GROUP
response = self.app.post(
- url('edit_user_group_default_perms_update', id=ug.users_group_id),
+ base.url('edit_user_group_default_perms_update', id=ug.users_group_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
response.follow()
@@ -118,7 +118,7 @@ class TestAdminUsersGroupsController(Tes
# DELETE !
ug = UserGroup.get_by_group_name(users_group_name)
ugid = ug.users_group_id
- response = self.app.post(url('delete_users_group', id=ug.users_group_id),
+ response = self.app.post(base.url('delete_users_group', id=ug.users_group_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
response = response.follow()
gr = Session().query(UserGroup) \
@@ -135,7 +135,7 @@ class TestAdminUsersGroupsController(Tes
def test_default_perms_enable_repository_fork_on_group(self):
self.log_user()
users_group_name = TEST_USER_GROUP + 'another2'
- response = self.app.post(url('users_groups'),
+ response = self.app.post(base.url('users_groups'),
{'users_group_name': users_group_name,
'user_group_description': u'DESC',
'active': True,
@@ -146,7 +146,7 @@ class TestAdminUsersGroupsController(Tes
self.checkSessionFlash(response,
'Created user group ')
## ENABLE REPO CREATE ON A GROUP
- response = self.app.post(url('edit_user_group_default_perms_update',
+ response = self.app.post(base.url('edit_user_group_default_perms_update',
id=ug.users_group_id),
{'fork_repo_perm': True, '_session_csrf_secret_token': self.session_csrf_secret_token()})
@@ -165,7 +165,7 @@ class TestAdminUsersGroupsController(Tes
[ug.users_group_id, p3.permission_id]])
## DISABLE REPO CREATE ON A GROUP
- response = self.app.post(url('edit_user_group_default_perms_update', id=ug.users_group_id),
+ response = self.app.post(base.url('edit_user_group_default_perms_update', id=ug.users_group_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
response.follow()
@@ -185,7 +185,7 @@ class TestAdminUsersGroupsController(Tes
# DELETE !
ug = UserGroup.get_by_group_name(users_group_name)
ugid = ug.users_group_id
- response = self.app.post(url('delete_users_group', id=ug.users_group_id),
+ response = self.app.post(base.url('delete_users_group', id=ug.users_group_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
response = response.follow()
gr = Session().query(UserGroup) \
@@ -201,5 +201,5 @@ class TestAdminUsersGroupsController(Tes
assert perms == []
def test_delete_browser_fakeout(self):
- response = self.app.post(url('delete_users_group', id=1),
+ response = self.app.post(base.url('delete_users_group', id=1),
params=dict(_session_csrf_secret_token=self.session_csrf_secret_token()))
diff --git a/kallithea/tests/functional/test_admin_users.py b/kallithea/tests/functional/test_admin_users.py
--- a/kallithea/tests/functional/test_admin_users.py
+++ b/kallithea/tests/functional/test_admin_users.py
@@ -24,7 +24,7 @@ from kallithea.model import validators
from kallithea.model.db import Permission, RepoGroup, User, UserApiKeys, UserSshKeys
from kallithea.model.meta import Session
from kallithea.model.user import UserModel
-from kallithea.tests.base import *
+from kallithea.tests import base
from kallithea.tests.fixture import Fixture
@@ -43,7 +43,7 @@ def user_and_repo_group_fail():
fixture.destroy_repo_group(repo_group)
-class TestAdminUsersController(TestController):
+class TestAdminUsersController(base.TestController):
test_user_1 = 'testme'
@classmethod
@@ -54,7 +54,7 @@ class TestAdminUsersController(TestContr
def test_index(self):
self.log_user()
- response = self.app.get(url('users'))
+ response = self.app.get(base.url('users'))
# TODO: Test response...
def test_create(self):
@@ -66,7 +66,7 @@ class TestAdminUsersController(TestContr
lastname = u'lastname'
email = 'mail@example.com'
- response = self.app.post(url('new_user'),
+ response = self.app.post(base.url('new_user'),
{'username': username,
'password': password,
'password_confirmation': password_confirmation,
@@ -102,7 +102,7 @@ class TestAdminUsersController(TestContr
lastname = u'lastname'
email = 'errmail.example.com'
- response = self.app.post(url('new_user'),
+ response = self.app.post(base.url('new_user'),
{'username': username,
'password': password,
'name': name,
@@ -126,9 +126,9 @@ class TestAdminUsersController(TestContr
def test_new(self):
self.log_user()
- response = self.app.get(url('new_user'))
+ response = self.app.get(base.url('new_user'))
- @parametrize('name,attrs',
+ @base.parametrize('name,attrs',
[('firstname', {'firstname': 'new_username'}),
('lastname', {'lastname': 'new_username'}),
('admin', {'admin': True}),
@@ -167,7 +167,7 @@ class TestAdminUsersController(TestContr
# not filled so we use creation data
params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()})
- response = self.app.post(url('update_user', id=usr.user_id), params)
+ response = self.app.post(base.url('update_user', id=usr.user_id), params)
self.checkSessionFlash(response, 'User updated successfully')
params.pop('_session_csrf_secret_token')
@@ -186,7 +186,7 @@ class TestAdminUsersController(TestContr
new_user = Session().query(User) \
.filter(User.username == username).one()
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Successfully deleted user')
@@ -201,18 +201,18 @@ class TestAdminUsersController(TestContr
new_user = Session().query(User) \
.filter(User.username == username).one()
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'User "%s" still '
'owns 1 repositories and cannot be removed. '
'Switch owners or remove those repositories: '
'%s' % (username, reponame))
- response = self.app.post(url('delete_repo', repo_name=reponame),
+ response = self.app.post(base.url('delete_repo', repo_name=reponame),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Deleted repository %s' % reponame)
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Successfully deleted user')
@@ -223,7 +223,7 @@ class TestAdminUsersController(TestContr
self.log_user()
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'User "%s" still '
'owns 1 repository groups and cannot be removed. '
@@ -232,13 +232,13 @@ class TestAdminUsersController(TestContr
# Relevant _if_ the user deletion succeeded to make sure we can render groups without owner
# rg = RepoGroup.get_by_group_name(group_name=groupname)
- # response = self.app.get(url('repos_groups', id=rg.group_id))
+ # response = self.app.get(base.url('repos_groups', id=rg.group_id))
- response = self.app.post(url('delete_repo_group', group_name=groupname),
+ response = self.app.post(base.url('delete_repo_group', group_name=groupname),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Removed repository group %s' % groupname)
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Successfully deleted user')
@@ -252,7 +252,7 @@ class TestAdminUsersController(TestContr
new_user = Session().query(User) \
.filter(User.username == username).one()
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'User "%s" still '
'owns 1 user groups and cannot be removed. '
@@ -260,19 +260,19 @@ class TestAdminUsersController(TestContr
'%s' % (username, groupname))
# TODO: why do this fail?
- #response = self.app.delete(url('delete_users_group', id=groupname))
+ #response = self.app.delete(base.url('delete_users_group', id=groupname))
#self.checkSessionFlash(response, 'Removed user group %s' % groupname)
fixture.destroy_user_group(ug.users_group_id)
- response = self.app.post(url('delete_user', id=new_user.user_id),
+ response = self.app.post(base.url('delete_user', id=new_user.user_id),
params={'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'Successfully deleted user')
def test_edit(self):
self.log_user()
- user = User.get_by_username(TEST_USER_ADMIN_LOGIN)
- response = self.app.get(url('edit_user', id=user.user_id))
+ user = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
+ response = self.app.get(base.url('edit_user', id=user.user_id))
def test_add_perm_create_repo(self):
self.log_user()
@@ -290,7 +290,7 @@ class TestAdminUsersController(TestContr
assert UserModel().has_perm(user, perm_none) == False
assert UserModel().has_perm(user, perm_create) == False
- response = self.app.post(url('edit_user_perms_update', id=uid),
+ response = self.app.post(base.url('edit_user_perms_update', id=uid),
params=dict(create_repo_perm=True,
_session_csrf_secret_token=self.session_csrf_secret_token()))
@@ -320,7 +320,7 @@ class TestAdminUsersController(TestContr
assert UserModel().has_perm(user, perm_none) == False
assert UserModel().has_perm(user, perm_create) == False
- response = self.app.post(url('edit_user_perms_update', id=uid),
+ response = self.app.post(base.url('edit_user_perms_update', id=uid),
params=dict(_session_csrf_secret_token=self.session_csrf_secret_token()))
perm_none = Permission.get_by_key('hg.create.none')
@@ -349,7 +349,7 @@ class TestAdminUsersController(TestContr
assert UserModel().has_perm(user, perm_none) == False
assert UserModel().has_perm(user, perm_fork) == False
- response = self.app.post(url('edit_user_perms_update', id=uid),
+ response = self.app.post(base.url('edit_user_perms_update', id=uid),
params=dict(create_repo_perm=True,
_session_csrf_secret_token=self.session_csrf_secret_token()))
@@ -379,7 +379,7 @@ class TestAdminUsersController(TestContr
assert UserModel().has_perm(user, perm_none) == False
assert UserModel().has_perm(user, perm_fork) == False
- response = self.app.post(url('edit_user_perms_update', id=uid),
+ response = self.app.post(base.url('edit_user_perms_update', id=uid),
params=dict(_session_csrf_secret_token=self.session_csrf_secret_token()))
perm_none = Permission.get_by_key('hg.create.none')
@@ -394,11 +394,11 @@ class TestAdminUsersController(TestContr
def test_ips(self):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
- response = self.app.get(url('edit_user_ips', id=user.user_id))
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
+ response = self.app.get(base.url('edit_user_ips', id=user.user_id))
response.mustcontain('All IP addresses are allowed')
- @parametrize('test_name,ip,ip_range,failure', [
+ @base.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),
@@ -408,26 +408,26 @@ class TestAdminUsersController(TestContr
])
def test_add_ip(self, test_name, ip, ip_range, failure, auto_clear_ip_permissions):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
- response = self.app.post(url('edit_user_ips_update', id=user_id),
+ response = self.app.post(base.url('edit_user_ips_update', id=user_id),
params=dict(new_ip=ip, _session_csrf_secret_token=self.session_csrf_secret_token()))
if failure:
self.checkSessionFlash(response, 'Please enter a valid IPv4 or IPv6 address')
- response = self.app.get(url('edit_user_ips', id=user_id))
+ response = self.app.get(base.url('edit_user_ips', id=user_id))
response.mustcontain(no=[ip])
response.mustcontain(no=[ip_range])
else:
- response = self.app.get(url('edit_user_ips', id=user_id))
+ response = self.app.get(base.url('edit_user_ips', id=user_id))
response.mustcontain(ip)
response.mustcontain(ip_range)
def test_delete_ip(self, auto_clear_ip_permissions):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
ip = '127.0.0.1/32'
ip_range = '127.0.0.1 - 127.0.0.1'
@@ -436,14 +436,14 @@ class TestAdminUsersController(TestContr
Session().commit()
new_ip_id = new_ip.ip_id
- response = self.app.get(url('edit_user_ips', id=user_id))
+ response = self.app.get(base.url('edit_user_ips', id=user_id))
response.mustcontain(ip)
response.mustcontain(ip_range)
- self.app.post(url('edit_user_ips_delete', id=user_id),
+ self.app.post(base.url('edit_user_ips_delete', id=user_id),
params=dict(del_ip_id=new_ip_id, _session_csrf_secret_token=self.session_csrf_secret_token()))
- response = self.app.get(url('edit_user_ips', id=user_id))
+ response = self.app.get(base.url('edit_user_ips', id=user_id))
response.mustcontain('All IP addresses are allowed')
response.mustcontain(no=[ip])
response.mustcontain(no=[ip_range])
@@ -451,22 +451,22 @@ class TestAdminUsersController(TestContr
def test_api_keys(self):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
- response = self.app.get(url('edit_user_api_keys', id=user.user_id))
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
+ response = self.app.get(base.url('edit_user_api_keys', id=user.user_id))
response.mustcontain(user.api_key)
response.mustcontain('Expires: Never')
- @parametrize('desc,lifetime', [
+ @base.parametrize('desc,lifetime', [
('forever', -1),
('5mins', 60*5),
('30days', 60*60*24*30),
])
def test_add_api_keys(self, desc, lifetime):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
- response = self.app.post(url('edit_user_api_keys_update', id=user_id),
+ response = self.app.post(base.url('edit_user_api_keys_update', id=user_id),
{'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'API key successfully created')
try:
@@ -481,10 +481,10 @@ class TestAdminUsersController(TestContr
def test_remove_api_key(self):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
- response = self.app.post(url('edit_user_api_keys_update', id=user_id),
+ response = self.app.post(base.url('edit_user_api_keys_update', id=user_id),
{'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'API key successfully created')
response = response.follow()
@@ -493,7 +493,7 @@ class TestAdminUsersController(TestContr
keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all()
assert 1 == len(keys)
- response = self.app.post(url('edit_user_api_keys_delete', id=user_id),
+ response = self.app.post(base.url('edit_user_api_keys_delete', id=user_id),
{'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'API key successfully deleted')
keys = UserApiKeys.query().filter(UserApiKeys.user_id == user_id).all()
@@ -501,14 +501,14 @@ class TestAdminUsersController(TestContr
def test_reset_main_api_key(self):
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
api_key = user.api_key
- response = self.app.get(url('edit_user_api_keys', id=user_id))
+ response = self.app.get(base.url('edit_user_api_keys', id=user_id))
response.mustcontain(api_key)
response.mustcontain('Expires: Never')
- response = self.app.post(url('edit_user_api_keys_delete', id=user_id),
+ response = self.app.post(base.url('edit_user_api_keys_delete', id=user_id),
{'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'API key successfully reset')
response = response.follow()
@@ -520,10 +520,10 @@ class TestAdminUsersController(TestContr
fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
- response = self.app.post(url('edit_user_ssh_keys', id=user_id),
+ response = self.app.post(base.url('edit_user_ssh_keys', id=user_id),
{'description': description,
'public_key': public_key,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
@@ -543,10 +543,10 @@ class TestAdminUsersController(TestContr
fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
self.log_user()
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
user_id = user.user_id
- response = self.app.post(url('edit_user_ssh_keys', id=user_id),
+ response = self.app.post(base.url('edit_user_ssh_keys', id=user_id),
{'description': description,
'public_key': public_key,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
@@ -555,7 +555,7 @@ class TestAdminUsersController(TestContr
ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one()
assert ssh_key.description == u'me@localhost'
- response = self.app.post(url('edit_user_ssh_keys_delete', id=user_id),
+ response = self.app.post(base.url('edit_user_ssh_keys_delete', id=user_id),
{'del_public_key': ssh_key.public_key,
'_session_csrf_secret_token': self.session_csrf_secret_token()})
self.checkSessionFlash(response, 'SSH key successfully deleted')
@@ -563,7 +563,7 @@ class TestAdminUsersController(TestContr
assert 0 == len(keys)
-class TestAdminUsersController_unittest(TestController):
+class TestAdminUsersController_unittest(base.TestController):
""" Unit tests for the users controller """
def test_get_user_or_raise_if_default(self, monkeypatch, test_context_fixture):
@@ -574,14 +574,14 @@ class TestAdminUsersController_unittest(
u = UsersController()
# a regular user should work correctly
- user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+ user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
assert u._get_user_or_raise_if_default(user.user_id) == user
# the default user should raise
with pytest.raises(HTTPNotFound):
u._get_user_or_raise_if_default(User.get_default_user().user_id)
-class TestAdminUsersControllerForDefaultUser(TestController):
+class TestAdminUsersControllerForDefaultUser(base.TestController):
"""
Edit actions on the default user are not allowed.
Validate that they throw a 404 exception.
@@ -589,59 +589,59 @@ class TestAdminUsersControllerForDefault
def test_edit_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user', id=user.user_id), status=404)
def test_edit_advanced_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user_advanced', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user_advanced', id=user.user_id), status=404)
# API keys
def test_edit_api_keys_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user_api_keys', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user_api_keys', id=user.user_id), status=404)
def test_add_api_keys_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.post(url('edit_user_api_keys_update', id=user.user_id),
+ response = self.app.post(base.url('edit_user_api_keys_update', id=user.user_id),
{'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404)
def test_delete_api_keys_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.post(url('edit_user_api_keys_delete', id=user.user_id),
+ response = self.app.post(base.url('edit_user_api_keys_delete', id=user.user_id),
{'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404)
# Permissions
def test_edit_perms_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user_perms', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user_perms', id=user.user_id), status=404)
def test_update_perms_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.post(url('edit_user_perms_update', id=user.user_id),
+ response = self.app.post(base.url('edit_user_perms_update', id=user.user_id),
{'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404)
# Emails
def test_edit_emails_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user_emails', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user_emails', id=user.user_id), status=404)
def test_add_emails_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.post(url('edit_user_emails_update', id=user.user_id),
+ response = self.app.post(base.url('edit_user_emails_update', id=user.user_id),
{'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404)
def test_delete_emails_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.post(url('edit_user_emails_delete', id=user.user_id),
+ response = self.app.post(base.url('edit_user_emails_delete', id=user.user_id),
{'_session_csrf_secret_token': self.session_csrf_secret_token()}, status=404)
# IP addresses
@@ -650,4 +650,4 @@ class TestAdminUsersControllerForDefault
def test_edit_ip_default_user(self):
self.log_user()
user = User.get_default_user()
- response = self.app.get(url('edit_user_ips', id=user.user_id), status=404)
+ response = self.app.get(base.url('edit_user_ips', id=user.user_id), status=404)
diff --git a/kallithea/tests/functional/test_changelog.py b/kallithea/tests/functional/test_changelog.py
--- a/kallithea/tests/functional/test_changelog.py
+++ b/kallithea/tests/functional/test_changelog.py
@@ -1,12 +1,12 @@
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestChangelogController(TestController):
+class TestChangelogController(base.TestController):
def test_index_hg(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO))
+ response = self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO))
response.mustcontain('''id="chg_20" class="mergerow"''')
response.mustcontain(
@@ -17,7 +17,7 @@ class TestChangelogController(TestContro
)
# rev 640: code garden
response.mustcontain(
- """r640:0a4e54a44604""" % HG_REPO
+ """r640:0a4e54a44604""" % base.HG_REPO
)
response.mustcontain("""code garden""")
@@ -26,18 +26,18 @@ class TestChangelogController(TestContro
def test_index_pagination_hg(self):
self.log_user()
# pagination
- self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 1})
- self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 2})
- self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 3})
- self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 4})
- self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 5})
- response = self.app.get(url(controller='changelog', action='index',
- repo_name=HG_REPO), {'page': 6, 'size': 20})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 1})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 2})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 3})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 4})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 5})
+ response = self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.HG_REPO), {'page': 6, 'size': 20})
# Test response after pagination...
response.mustcontain(
@@ -53,8 +53,8 @@ class TestChangelogController(TestContro
def test_index_git(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO))
+ response = self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO))
response.mustcontain('''id="chg_20" class=""''') # why no mergerow for git?
response.mustcontain(
@@ -82,18 +82,18 @@ class TestChangelogController(TestContro
def test_index_pagination_git(self):
self.log_user()
# pagination
- self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 1})
- self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 2})
- self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 3})
- self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 4})
- self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 5})
- response = self.app.get(url(controller='changelog', action='index',
- repo_name=GIT_REPO), {'page': 6, 'size': 20})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 1})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 2})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 3})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 4})
+ self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 5})
+ response = self.app.get(base.url(controller='changelog', action='index',
+ repo_name=base.GIT_REPO), {'page': 6, 'size': 20})
# Test response after pagination...
response.mustcontain(
@@ -109,9 +109,9 @@ class TestChangelogController(TestContro
def test_index_hg_with_filenode(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/vcs/exceptions.py',
- repo_name=HG_REPO))
+ repo_name=base.HG_REPO))
# history commits messages
response.mustcontain('Added exceptions module, this time for real')
response.mustcontain('Added not implemented hg backend test case')
@@ -120,9 +120,9 @@ class TestChangelogController(TestContro
def test_index_git_with_filenode(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/vcs/exceptions.py',
- repo_name=GIT_REPO))
+ repo_name=base.GIT_REPO))
# history commits messages
response.mustcontain('Added exceptions module, this time for real')
response.mustcontain('Added not implemented hg backend test case')
@@ -130,28 +130,28 @@ class TestChangelogController(TestContro
def test_index_hg_with_filenode_that_is_dirnode(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/tests',
- repo_name=HG_REPO))
+ repo_name=base.HG_REPO))
assert response.status == '302 Found'
def test_index_git_with_filenode_that_is_dirnode(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/tests',
- repo_name=GIT_REPO))
+ repo_name=base.GIT_REPO))
assert response.status == '302 Found'
def test_index_hg_with_filenode_not_existing(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/wrong_path',
- repo_name=HG_REPO))
+ repo_name=base.HG_REPO))
assert response.status == '302 Found'
def test_index_git_with_filenode_not_existing(self):
self.log_user()
- response = self.app.get(url(controller='changelog', action='index',
+ response = self.app.get(base.url(controller='changelog', action='index',
revision='tip', f_path='/wrong_path',
- repo_name=GIT_REPO))
+ repo_name=base.GIT_REPO))
assert response.status == '302 Found'
diff --git a/kallithea/tests/functional/test_changeset.py b/kallithea/tests/functional/test_changeset.py
--- a/kallithea/tests/functional/test_changeset.py
+++ b/kallithea/tests/functional/test_changeset.py
@@ -1,24 +1,24 @@
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestChangesetController(TestController):
+class TestChangesetController(base.TestController):
def test_index(self):
- response = self.app.get(url(controller='changeset', action='index',
- repo_name=HG_REPO, revision='tip'))
+ response = self.app.get(base.url(controller='changeset', action='index',
+ repo_name=base.HG_REPO, revision='tip'))
# Test response...
def test_changeset_range(self):
- #print self.app.get(url(controller='changelog', action='index', repo_name=HG_REPO))
+ #print self.app.get(base.url(controller='changelog', action='index', repo_name=base.HG_REPO))
- response = self.app.get(url(controller='changeset', action='index',
- repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52...96507bd11ecc815ebc6270fdf6db110928c09c1e'))
+ response = self.app.get(base.url(controller='changeset', action='index',
+ repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52...96507bd11ecc815ebc6270fdf6db110928c09c1e'))
- response = self.app.get(url(controller='changeset', action='changeset_raw',
- repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
+ response = self.app.get(base.url(controller='changeset', action='changeset_raw',
+ repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
- response = self.app.get(url(controller='changeset', action='changeset_patch',
- repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
+ response = self.app.get(base.url(controller='changeset', action='changeset_patch',
+ repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
- response = self.app.get(url(controller='changeset', action='changeset_download',
- repo_name=HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
+ response = self.app.get(base.url(controller='changeset', action='changeset_download',
+ repo_name=base.HG_REPO, revision='a53d9201d4bc278910d416d94941b7ea007ecd52'))
diff --git a/kallithea/tests/functional/test_changeset_pullrequests_comments.py b/kallithea/tests/functional/test_changeset_pullrequests_comments.py
--- a/kallithea/tests/functional/test_changeset_pullrequests_comments.py
+++ b/kallithea/tests/functional/test_changeset_pullrequests_comments.py
@@ -3,10 +3,10 @@ import re
from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.db import ChangesetComment, PullRequest
from kallithea.model.meta import Session
-from kallithea.tests.base import *
+from kallithea.tests import base
-class TestChangeSetCommentsController(TestController):
+class TestChangeSetCommentsController(base.TestController):
def setup_method(self, method):
for x in ChangesetComment.query().all():
@@ -19,14 +19,14 @@ class TestChangeSetCommentsController(Te
text = u'general comment on changeset'
params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
- response = self.app.post(url(controller='changeset', action='comment',
- repo_name=HG_REPO, revision=rev),
+ response = self.app.post(base.url(controller='changeset', action='comment',
+ repo_name=base.HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
- response = self.app.get(url(controller='changeset', action='index',
- repo_name=HG_REPO, revision=rev))
+ response = self.app.get(base.url(controller='changeset', action='index',
+ repo_name=base.HG_REPO, revision=rev))
response.mustcontain(
'''
%s
""" % datetime.date.today()) @@ -22,18 +22,18 @@ class TestJournalController(TestControll # # assert len(followings) == 1, 'Not following any repository' # -# response = self.app.post(url(controller='journal', +# response = self.app.post(base.url(controller='journal', # action='toggle_following'), # {'follows_repository_id':repo.repo_id}) def test_start_following_repository(self): self.log_user() - response = self.app.get(url(controller='journal', action='index'),) + response = self.app.get(base.url(controller='journal', action='index'),) def test_public_journal_atom(self): self.log_user() - response = self.app.get(url(controller='journal', action='public_journal_atom'),) + response = self.app.get(base.url(controller='journal', action='public_journal_atom'),) def test_public_journal_rss(self): self.log_user() - response = self.app.get(url(controller='journal', action='public_journal_rss'),) + response = self.app.get(base.url(controller='journal', action='public_journal_rss'),) diff --git a/kallithea/tests/functional/test_login.py b/kallithea/tests/functional/test_login.py --- a/kallithea/tests/functional/test_login.py +++ b/kallithea/tests/functional/test_login.py @@ -13,61 +13,61 @@ from kallithea.model.api_key import ApiK from kallithea.model.db import User from kallithea.model.meta import Session from kallithea.model.user import UserModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestLoginController(TestController): +class TestLoginController(base.TestController): def test_index(self): - response = self.app.get(url(controller='login', action='index')) + response = self.app.get(base.url(controller='login', action='index')) assert response.status == '200 OK' # Test response... def test_login_admin_ok(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_ADMIN_LOGIN, - 'password': TEST_USER_ADMIN_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_ADMIN_LOGIN, + 'password': base.TEST_USER_ADMIN_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '302 Found' - self.assert_authenticated_user(response, TEST_USER_ADMIN_LOGIN) + self.assert_authenticated_user(response, base.TEST_USER_ADMIN_LOGIN) response = response.follow() - response.mustcontain('/%s' % HG_REPO) + response.mustcontain('/%s' % base.HG_REPO) def test_login_regular_ok(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_LOGIN, - 'password': TEST_USER_REGULAR_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_LOGIN, + 'password': base.TEST_USER_REGULAR_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '302 Found' - self.assert_authenticated_user(response, TEST_USER_REGULAR_LOGIN) + self.assert_authenticated_user(response, base.TEST_USER_REGULAR_LOGIN) response = response.follow() - response.mustcontain('/%s' % HG_REPO) + response.mustcontain('/%s' % base.HG_REPO) def test_login_regular_email_ok(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_EMAIL, - 'password': TEST_USER_REGULAR_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_EMAIL, + 'password': base.TEST_USER_REGULAR_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '302 Found' - self.assert_authenticated_user(response, TEST_USER_REGULAR_LOGIN) + self.assert_authenticated_user(response, base.TEST_USER_REGULAR_LOGIN) response = response.follow() - response.mustcontain('/%s' % HG_REPO) + response.mustcontain('/%s' % base.HG_REPO) def test_login_ok_came_from(self): test_came_from = '/_admin/users' - response = self.app.post(url(controller='login', action='index', + response = self.app.post(base.url(controller='login', action='index', came_from=test_came_from), - {'username': TEST_USER_ADMIN_LOGIN, - 'password': TEST_USER_ADMIN_PASS, + {'username': base.TEST_USER_ADMIN_LOGIN, + 'password': base.TEST_USER_ADMIN_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '302 Found' response = response.follow() @@ -76,9 +76,9 @@ class TestLoginController(TestController response.mustcontain('Users Administration') def test_login_do_not_remember(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_LOGIN, - 'password': TEST_USER_REGULAR_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_LOGIN, + 'password': base.TEST_USER_REGULAR_PASS, 'remember': False, '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -87,9 +87,9 @@ class TestLoginController(TestController assert not re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r has expiration date, but should be a session cookie' % cookie def test_login_remember(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_LOGIN, - 'password': TEST_USER_REGULAR_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_LOGIN, + 'password': base.TEST_USER_REGULAR_PASS, 'remember': True, '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -98,23 +98,23 @@ class TestLoginController(TestController assert re.search(r';\s+(Max-Age|Expires)=', cookie, re.IGNORECASE), 'Cookie %r should have expiration date, but is a session cookie' % cookie def test_logout(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_LOGIN, - 'password': TEST_USER_REGULAR_PASS, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_LOGIN, + 'password': base.TEST_USER_REGULAR_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) # Verify that a login session has been established. - response = self.app.get(url(controller='login', action='index')) + response = self.app.get(base.url(controller='login', action='index')) response = response.follow() assert 'authuser' in response.session response.click('Log Out') # Verify that the login session has been terminated. - response = self.app.get(url(controller='login', action='index')) + response = self.app.get(base.url(controller='login', action='index')) assert 'authuser' not in response.session - @parametrize('url_came_from', [ + @base.parametrize('url_came_from', [ ('data:text/html,',), ('mailto:test@example.com',), ('file:///etc/passwd',), @@ -126,16 +126,16 @@ class TestLoginController(TestController ('non-absolute-path',), ]) def test_login_bad_came_froms(self, url_came_from): - response = self.app.post(url(controller='login', action='index', + response = self.app.post(base.url(controller='login', action='index', came_from=url_came_from), - {'username': TEST_USER_ADMIN_LOGIN, - 'password': TEST_USER_ADMIN_PASS, + {'username': base.TEST_USER_ADMIN_LOGIN, + 'password': base.TEST_USER_ADMIN_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}, status=400) def test_login_short_password(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_ADMIN_LOGIN, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_ADMIN_LOGIN, 'password': 'as', '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '200 OK' @@ -143,7 +143,7 @@ class TestLoginController(TestController response.mustcontain('Enter 3 characters or more') def test_login_wrong_username_password(self): - response = self.app.post(url(controller='login', action='index'), + response = self.app.post(base.url(controller='login', action='index'), {'username': 'error', 'password': 'test12', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -151,8 +151,8 @@ class TestLoginController(TestController response.mustcontain('Invalid username or password') def test_login_non_ascii(self): - response = self.app.post(url(controller='login', action='index'), - {'username': TEST_USER_REGULAR_LOGIN, + response = self.app.post(base.url(controller='login', action='index'), + {'username': base.TEST_USER_REGULAR_LOGIN, 'password': 'blåbærgrød', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -160,55 +160,55 @@ class TestLoginController(TestController # verify that get arguments are correctly passed along login redirection - @parametrize('args', [ + @base.parametrize('args', [ {'foo':'one', 'bar':'two'}, {'blue': u'blå', 'green': u'grøn'}, ]) def test_redirection_to_login_form_preserves_get_args(self, args): with fixture.anon_access(False): - response = self.app.get(url(controller='summary', action='index', - repo_name=HG_REPO, + response = self.app.get(base.url(controller='summary', action='index', + repo_name=base.HG_REPO, **args)) assert response.status == '302 Found' came_from = urlparse.parse_qs(urlparse.urlparse(response.location).query)['came_from'][0] came_from_qs = urlparse.parse_qsl(urlparse.urlparse(came_from).query) assert sorted(came_from_qs) == sorted((k, v.encode('utf-8')) for k, v in args.items()) - @parametrize('args,args_encoded', [ + @base.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')), ]) def test_login_form_preserves_get_args(self, args, args_encoded): - response = self.app.get(url(controller='login', action='index', - came_from=url('/_admin/users', **args))) + response = self.app.get(base.url(controller='login', action='index', + came_from=base.url('/_admin/users', **args))) came_from = urlparse.parse_qs(urlparse.urlparse(response.form.action).query)['came_from'][0] for encoded in args_encoded: assert encoded in came_from - @parametrize('args,args_encoded', [ + @base.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')), ]) def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded): - response = self.app.post(url(controller='login', action='index', - came_from=url('/_admin/users', **args)), - {'username': TEST_USER_ADMIN_LOGIN, - 'password': TEST_USER_ADMIN_PASS, + response = self.app.post(base.url(controller='login', action='index', + came_from=base.url('/_admin/users', **args)), + {'username': base.TEST_USER_ADMIN_LOGIN, + 'password': base.TEST_USER_ADMIN_PASS, '_session_csrf_secret_token': self.session_csrf_secret_token()}) assert response.status == '302 Found' for encoded in args_encoded: assert encoded in response.location - @parametrize('args,args_encoded', [ + @base.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')), ]) def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded): - response = self.app.post(url(controller='login', action='index', - came_from=url('/_admin/users', **args)), + response = self.app.post(base.url(controller='login', action='index', + came_from=base.url('/_admin/users', **args)), {'username': 'error', 'password': 'test12', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -222,12 +222,12 @@ class TestLoginController(TestController # REGISTRATIONS #========================================================================== def test_register(self): - response = self.app.get(url(controller='login', action='register')) + response = self.app.get(base.url(controller='login', action='register')) response.mustcontain('Sign Up') def test_register_err_same_username(self): - uname = TEST_USER_ADMIN_LOGIN - response = self.app.post(url(controller='login', action='register'), + uname = base.TEST_USER_ADMIN_LOGIN + response = self.app.post(base.url(controller='login', action='register'), {'username': uname, 'password': 'test12', 'password_confirmation': 'test12', @@ -242,11 +242,11 @@ class TestLoginController(TestController response.mustcontain(msg) def test_register_err_same_email(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'test_admin_0', 'password': 'test12', 'password_confirmation': 'test12', - 'email': TEST_USER_ADMIN_EMAIL, + 'email': base.TEST_USER_ADMIN_EMAIL, 'firstname': 'test', 'lastname': 'test', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -256,11 +256,11 @@ class TestLoginController(TestController response.mustcontain(msg) def test_register_err_same_email_case_sensitive(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'test_admin_1', 'password': 'test12', 'password_confirmation': 'test12', - 'email': TEST_USER_ADMIN_EMAIL.title(), + 'email': base.TEST_USER_ADMIN_EMAIL.title(), 'firstname': 'test', 'lastname': 'test', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -269,7 +269,7 @@ class TestLoginController(TestController response.mustcontain(msg) def test_register_err_wrong_data(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'xs', 'password': 'test', 'password_confirmation': 'test', @@ -282,7 +282,7 @@ class TestLoginController(TestController response.mustcontain('Enter a value 6 characters long or more') def test_register_err_username(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'error user', 'password': 'test12', 'password_confirmation': 'test12', @@ -298,8 +298,8 @@ class TestLoginController(TestController 'alphanumeric character') def test_register_err_case_sensitive(self): - usr = TEST_USER_ADMIN_LOGIN.title() - response = self.app.post(url(controller='login', action='register'), + usr = base.TEST_USER_ADMIN_LOGIN.title() + response = self.app.post(base.url(controller='login', action='register'), {'username': usr, 'password': 'test12', 'password_confirmation': 'test12', @@ -315,7 +315,7 @@ class TestLoginController(TestController response.mustcontain(msg) def test_register_special_chars(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'xxxaxn', 'password': 'ąćźżąśśśś', 'password_confirmation': 'ąćźżąśśśś', @@ -329,7 +329,7 @@ class TestLoginController(TestController response.mustcontain(msg) def test_register_password_mismatch(self): - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': 'xs', 'password': '123qwe', 'password_confirmation': 'qwe123', @@ -348,7 +348,7 @@ class TestLoginController(TestController name = 'testname' lastname = 'testlastname' - response = self.app.post(url(controller='login', action='register'), + response = self.app.post(base.url(controller='login', action='register'), {'username': username, 'password': password, 'password_confirmation': password, @@ -376,14 +376,14 @@ class TestLoginController(TestController def test_forgot_password_wrong_mail(self): bad_email = 'username%wrongmail.org' response = self.app.post( - url(controller='login', action='password_reset'), + base.url(controller='login', action='password_reset'), {'email': bad_email, '_session_csrf_secret_token': self.session_csrf_secret_token()}) response.mustcontain('An email address must contain a single @') def test_forgot_password(self): - response = self.app.get(url(controller='login', + response = self.app.get(base.url(controller='login', action='password_reset')) assert response.status == '200 OK' @@ -404,7 +404,7 @@ class TestLoginController(TestController Session().add(new) Session().commit() - response = self.app.post(url(controller='login', + response = self.app.post(base.url(controller='login', action='password_reset'), {'email': email, '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -417,7 +417,7 @@ class TestLoginController(TestController token = "bad" - response = self.app.post(url(controller='login', + response = self.app.post(base.url(controller='login', action='password_reset_confirmation'), {'email': email, 'timestamp': timestamp, @@ -437,7 +437,7 @@ class TestLoginController(TestController token = UserModel().get_reset_password_token( User.get_by_username(username), timestamp, self.session_csrf_secret_token()) - response = self.app.get(url(controller='login', + response = self.app.get(base.url(controller='login', action='password_reset_confirmation', email=email, timestamp=timestamp, @@ -445,7 +445,7 @@ class TestLoginController(TestController assert response.status == '200 OK' response.mustcontain("You are about to set a new password for the email address %s" % email) - response = self.app.post(url(controller='login', + response = self.app.post(base.url(controller='login', action='password_reset_confirmation'), {'email': email, 'timestamp': timestamp, @@ -481,16 +481,16 @@ class TestLoginController(TestController params = {'api_key': api_key} headers = {'Authorization': 'Bearer ' + str(api_key)} - self.app.get(url(controller='changeset', action='changeset_raw', - repo_name=HG_REPO, revision='tip', **params), + self.app.get(base.url(controller='changeset', action='changeset_raw', + repo_name=base.HG_REPO, revision='tip', **params), status=status) - self.app.get(url(controller='changeset', action='changeset_raw', - repo_name=HG_REPO, revision='tip'), + self.app.get(base.url(controller='changeset', action='changeset_raw', + repo_name=base.HG_REPO, revision='tip'), headers=headers, status=status) - @parametrize('test_name,api_key,code', [ + @base.parametrize('test_name,api_key,code', [ ('none', None, 302), ('empty_string', '', 403), ('fake_number', '123456', 403), @@ -502,12 +502,12 @@ class TestLoginController(TestController self._api_key_test(api_key, code) def test_access_page_via_extra_api_key(self): - new_api_key = ApiKeyModel().create(TEST_USER_ADMIN_LOGIN, u'test') + new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test') Session().commit() self._api_key_test(new_api_key.api_key, status=200) def test_access_page_via_expired_api_key(self): - new_api_key = ApiKeyModel().create(TEST_USER_ADMIN_LOGIN, u'test') + new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test') Session().commit() # patch the API key and make it expired new_api_key.expires = 0 diff --git a/kallithea/tests/functional/test_my_account.py b/kallithea/tests/functional/test_my_account.py --- a/kallithea/tests/functional/test_my_account.py +++ b/kallithea/tests/functional/test_my_account.py @@ -6,14 +6,14 @@ from kallithea.lib import helpers as h from kallithea.model.db import Repository, User, UserApiKeys, UserFollowing, UserSshKeys from kallithea.model.meta import Session from kallithea.model.user import UserModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestMyAccountController(TestController): +class TestMyAccountController(base.TestController): test_user_1 = 'testme' @classmethod @@ -24,74 +24,74 @@ class TestMyAccountController(TestContro def test_my_account(self): self.log_user() - response = self.app.get(url('my_account')) + response = self.app.get(base.url('my_account')) - response.mustcontain('value="%s' % TEST_USER_ADMIN_LOGIN) + response.mustcontain('value="%s' % base.TEST_USER_ADMIN_LOGIN) def test_my_account_my_repos(self): self.log_user() - response = self.app.get(url('my_account_repos')) + response = self.app.get(base.url('my_account_repos')) cnt = Repository.query().filter(Repository.owner == - User.get_by_username(TEST_USER_ADMIN_LOGIN)).count() - response.mustcontain('"raw_name": "%s"' % HG_REPO) - response.mustcontain('"just_name": "%s"' % GIT_REPO) + User.get_by_username(base.TEST_USER_ADMIN_LOGIN)).count() + response.mustcontain('"raw_name": "%s"' % base.HG_REPO) + response.mustcontain('"just_name": "%s"' % base.GIT_REPO) def test_my_account_my_watched(self): self.log_user() - response = self.app.get(url('my_account_watched')) + response = self.app.get(base.url('my_account_watched')) cnt = UserFollowing.query().filter(UserFollowing.user == - User.get_by_username(TEST_USER_ADMIN_LOGIN)).count() - response.mustcontain('"raw_name": "%s"' % HG_REPO) - response.mustcontain('"just_name": "%s"' % GIT_REPO) + User.get_by_username(base.TEST_USER_ADMIN_LOGIN)).count() + response.mustcontain('"raw_name": "%s"' % base.HG_REPO) + response.mustcontain('"just_name": "%s"' % base.GIT_REPO) def test_my_account_my_emails(self): self.log_user() - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) response.mustcontain('No additional emails specified') def test_my_account_my_emails_add_existing_email(self): self.log_user() - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) response.mustcontain('No additional emails specified') - response = self.app.post(url('my_account_emails'), - {'new_email': TEST_USER_REGULAR_EMAIL, '_session_csrf_secret_token': self.session_csrf_secret_token()}) + response = self.app.post(base.url('my_account_emails'), + {'new_email': base.TEST_USER_REGULAR_EMAIL, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'This email address is already in use') def test_my_account_my_emails_add_missing_email_in_form(self): self.log_user() - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) response.mustcontain('No additional emails specified') - response = self.app.post(url('my_account_emails'), + response = self.app.post(base.url('my_account_emails'), {'_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'Please enter an email address') def test_my_account_my_emails_add_remove(self): self.log_user() - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) response.mustcontain('No additional emails specified') - response = self.app.post(url('my_account_emails'), + response = self.app.post(base.url('my_account_emails'), {'new_email': 'barz@example.com', '_session_csrf_secret_token': self.session_csrf_secret_token()}) - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) from kallithea.model.db import UserEmailMap email_id = UserEmailMap.query() \ - .filter(UserEmailMap.user == User.get_by_username(TEST_USER_ADMIN_LOGIN)) \ + .filter(UserEmailMap.user == User.get_by_username(base.TEST_USER_ADMIN_LOGIN)) \ .filter(UserEmailMap.email == 'barz@example.com').one().email_id response.mustcontain('barz@example.com') response.mustcontain('' % email_id) - response = self.app.post(url('my_account_emails_delete'), + response = self.app.post(base.url('my_account_emails_delete'), {'del_email_id': email_id, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'Removed email from user') - response = self.app.get(url('my_account_emails')) + response = self.app.get(base.url('my_account_emails')) response.mustcontain('No additional emails specified') - @parametrize('name,attrs', + @base.parametrize('name,attrs', [('firstname', {'firstname': 'new_username'}), ('lastname', {'lastname': 'new_username'}), ('admin', {'admin': True}), @@ -123,7 +123,7 @@ class TestMyAccountController(TestContro params.update({'_session_csrf_secret_token': self.session_csrf_secret_token()}) params.update(attrs) - response = self.app.post(url('my_account'), params) + response = self.app.post(base.url('my_account'), params) self.checkSessionFlash(response, 'Your account was updated successfully') @@ -155,11 +155,11 @@ class TestMyAccountController(TestContro def test_my_account_update_err_email_exists(self): self.log_user() - new_email = TEST_USER_REGULAR_EMAIL # already existing email - response = self.app.post(url('my_account'), + new_email = base.TEST_USER_REGULAR_EMAIL # already existing email + response = self.app.post(base.url('my_account'), params=dict( - username=TEST_USER_ADMIN_LOGIN, - new_password=TEST_USER_ADMIN_PASS, + username=base.TEST_USER_ADMIN_LOGIN, + new_password=base.TEST_USER_ADMIN_PASS, password_confirmation='test122', firstname=u'NewName', lastname=u'NewLastname', @@ -170,13 +170,13 @@ class TestMyAccountController(TestContro response.mustcontain('This email address is already in use') def test_my_account_update_err(self): - self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) + self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) new_email = 'newmail.pl' - response = self.app.post(url('my_account'), + response = self.app.post(base.url('my_account'), params=dict( - username=TEST_USER_ADMIN_LOGIN, - new_password=TEST_USER_ADMIN_PASS, + username=base.TEST_USER_ADMIN_LOGIN, + new_password=base.TEST_USER_ADMIN_PASS, password_confirmation='test122', firstname=u'NewName', lastname=u'NewLastname', @@ -188,25 +188,25 @@ class TestMyAccountController(TestContro with test_context(self.app): msg = validators.ValidUsername(edit=False, old_data={}) \ ._messages['username_exists'] - msg = h.html_escape(msg % {'username': TEST_USER_ADMIN_LOGIN}) + msg = h.html_escape(msg % {'username': base.TEST_USER_ADMIN_LOGIN}) response.mustcontain(msg) def test_my_account_api_keys(self): - usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) + usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) user = User.get(usr['user_id']) - response = self.app.get(url('my_account_api_keys')) + response = self.app.get(base.url('my_account_api_keys')) response.mustcontain(user.api_key) response.mustcontain('Expires: Never') - @parametrize('desc,lifetime', [ + @base.parametrize('desc,lifetime', [ ('forever', -1), ('5mins', 60*5), ('30days', 60*60*24*30), ]) def test_my_account_add_api_keys(self, desc, lifetime): - usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) + usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) user = User.get(usr['user_id']) - response = self.app.post(url('my_account_api_keys'), + response = self.app.post(base.url('my_account_api_keys'), {'description': desc, 'lifetime': lifetime, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'API key successfully created') try: @@ -220,9 +220,9 @@ class TestMyAccountController(TestContro Session().commit() def test_my_account_remove_api_key(self): - usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) + usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) user = User.get(usr['user_id']) - response = self.app.post(url('my_account_api_keys'), + response = self.app.post(base.url('my_account_api_keys'), {'description': 'desc', 'lifetime': -1, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'API key successfully created') response = response.follow() @@ -231,21 +231,21 @@ class TestMyAccountController(TestContro keys = UserApiKeys.query().all() assert 1 == len(keys) - response = self.app.post(url('my_account_api_keys_delete'), + response = self.app.post(base.url('my_account_api_keys_delete'), {'del_api_key': keys[0].api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'API key successfully deleted') keys = UserApiKeys.query().all() assert 0 == len(keys) def test_my_account_reset_main_api_key(self): - usr = self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) + usr = self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) user = User.get(usr['user_id']) api_key = user.api_key - response = self.app.get(url('my_account_api_keys')) + response = self.app.get(base.url('my_account_api_keys')) response.mustcontain(api_key) response.mustcontain('Expires: Never') - response = self.app.post(url('my_account_api_keys_delete'), + response = self.app.post(base.url('my_account_api_keys_delete'), {'del_api_key_builtin': api_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'API key successfully reset') response = response.follow() @@ -256,8 +256,8 @@ class TestMyAccountController(TestContro public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' - self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) - response = self.app.post(url('my_account_ssh_keys'), + self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) + response = self.app.post(base.url('my_account_ssh_keys'), {'description': description, 'public_key': public_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -277,8 +277,8 @@ class TestMyAccountController(TestContro public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost' fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8' - self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) - response = self.app.post(url('my_account_ssh_keys'), + self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS) + response = self.app.post(base.url('my_account_ssh_keys'), {'description': description, 'public_key': public_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -288,7 +288,7 @@ class TestMyAccountController(TestContro ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() assert ssh_key.description == u'me@localhost' - response = self.app.post(url('my_account_ssh_keys_delete'), + response = self.app.post(base.url('my_account_ssh_keys_delete'), {'del_public_key': ssh_key.public_key, '_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'SSH key successfully deleted') diff --git a/kallithea/tests/functional/test_pullrequests.py b/kallithea/tests/functional/test_pullrequests.py --- a/kallithea/tests/functional/test_pullrequests.py +++ b/kallithea/tests/functional/test_pullrequests.py @@ -5,27 +5,27 @@ import pytest from kallithea.controllers.pullrequests import PullrequestsController from kallithea.model.db import PullRequest, User from kallithea.model.meta import Session -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestPullrequestsController(TestController): +class TestPullrequestsController(base.TestController): def test_index(self): self.log_user() - response = self.app.get(url(controller='pullrequests', action='index', - repo_name=HG_REPO)) + response = self.app.get(base.url(controller='pullrequests', action='index', + repo_name=base.HG_REPO)) def test_create_trivial(self): self.log_user() - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), - {'org_repo': HG_REPO, + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), + {'org_repo': base.HG_REPO, 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -40,11 +40,11 @@ class TestPullrequestsController(TestCon def test_available(self): self.log_user() - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), - {'org_repo': HG_REPO, + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), + {'org_repo': base.HG_REPO, 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -60,11 +60,11 @@ class TestPullrequestsController(TestCon def test_range(self): self.log_user() - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), - {'org_repo': HG_REPO, + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), + {'org_repo': base.HG_REPO, 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -78,16 +78,16 @@ class TestPullrequestsController(TestCon def test_update_reviewers(self): self.log_user() - regular_user = User.get_by_username(TEST_USER_REGULAR_LOGIN) - regular_user2 = User.get_by_username(TEST_USER_REGULAR2_LOGIN) - admin_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) + regular_user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) + regular_user2 = User.get_by_username(base.TEST_USER_REGULAR2_LOGIN) + admin_user = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) # create initial PR - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), - {'org_repo': HG_REPO, + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), + {'org_repo': base.HG_REPO, 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -95,40 +95,40 @@ class TestPullrequestsController(TestCon }, status=302) pull_request1_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) - assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request1_id) + assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request1_id) # create new iteration - response = self.app.post(url(controller='pullrequests', action='post', - repo_name=HG_REPO, pull_request_id=pull_request1_id), + response = self.app.post(base.url(controller='pullrequests', action='post', + repo_name=base.HG_REPO, pull_request_id=pull_request1_id), { 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_ADMIN_LOGIN, + 'owner': base.TEST_USER_ADMIN_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), 'review_members': [regular_user.user_id], }, status=302) pull_request2_id = re.search(r'/pull-request/(\d+)/', response.location).group(1) assert pull_request2_id != pull_request1_id - assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request2_id) + assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request2_id) response = response.follow() # verify reviewer was added response.mustcontain('' % regular_user.user_id) # update without creating new iteration - response = self.app.post(url(controller='pullrequests', action='post', - repo_name=HG_REPO, pull_request_id=pull_request2_id), + response = self.app.post(base.url(controller='pullrequests', action='post', + repo_name=base.HG_REPO, pull_request_id=pull_request2_id), { 'pullrequest_title': 'Title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_ADMIN_LOGIN, + 'owner': base.TEST_USER_ADMIN_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), 'org_review_members': [admin_user.user_id], # fake - just to get some 'meanwhile' warning ... but it is also added ... 'review_members': [regular_user2.user_id, admin_user.user_id], }, status=302) - assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (HG_REPO, pull_request2_id) + assert response.location == 'http://localhost/%s/pull-request/%s/_/stable' % (base.HG_REPO, pull_request2_id) response = response.follow() # verify reviewers were added / removed response.mustcontain('Meanwhile, the following reviewers have been added: test_regular') @@ -141,12 +141,12 @@ class TestPullrequestsController(TestCon invalid_user_id = 99999 self.log_user() # create a valid pull request - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), { - 'org_repo': HG_REPO, + 'org_repo': base.HG_REPO, 'org_ref': 'rev:94f45ed825a1:94f45ed825a113e61af7e141f44ca578374abef0', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -160,13 +160,13 @@ class TestPullrequestsController(TestCon pull_request_id = m.group(1) # update it - response = self.app.post(url(controller='pullrequests', action='post', - repo_name=HG_REPO, pull_request_id=pull_request_id), + response = self.app.post(base.url(controller='pullrequests', action='post', + repo_name=base.HG_REPO, pull_request_id=pull_request_id), { 'updaterev': '4f7e2131323e0749a740c0a56ab68ae9269c562a', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_ADMIN_LOGIN, + 'owner': base.TEST_USER_ADMIN_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), 'review_members': [str(invalid_user_id)], }, @@ -177,12 +177,12 @@ class TestPullrequestsController(TestCon invalid_user_id = 99999 self.log_user() # create a valid pull request - response = self.app.post(url(controller='pullrequests', action='create', - repo_name=HG_REPO), + response = self.app.post(base.url(controller='pullrequests', action='create', + repo_name=base.HG_REPO), { - 'org_repo': HG_REPO, + 'org_repo': base.HG_REPO, 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -196,12 +196,12 @@ class TestPullrequestsController(TestCon pull_request_id = m.group(1) # edit it - response = self.app.post(url(controller='pullrequests', action='post', - repo_name=HG_REPO, pull_request_id=pull_request_id), + response = self.app.post(base.url(controller='pullrequests', action='post', + repo_name=base.HG_REPO, pull_request_id=pull_request_id), { 'pullrequest_title': 'title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_ADMIN_LOGIN, + 'owner': base.TEST_USER_ADMIN_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), 'review_members': [str(invalid_user_id)], }, @@ -226,11 +226,11 @@ class TestPullrequestsController(TestCon # create initial PR response = self.app.post( - url(controller='pullrequests', action='create', repo_name=HG_REPO), + base.url(controller='pullrequests', action='create', repo_name=base.HG_REPO), { - 'org_repo': HG_REPO, + 'org_repo': base.HG_REPO, 'org_ref': 'rev:9e6119747791:9e6119747791ff886a5abe1193a730b6bf874e1c', - 'other_repo': HG_REPO, + 'other_repo': base.HG_REPO, 'other_ref': 'branch:default:3d1091ee5a533b1f4577ec7d8a226bb315fb1336', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', @@ -247,12 +247,12 @@ class TestPullrequestsController(TestCon # create PR 2 (new iteration with same ancestor) response = self.app.post( - url(controller='pullrequests', action='post', repo_name=HG_REPO, pull_request_id=pr1_id), + base.url(controller='pullrequests', action='post', repo_name=base.HG_REPO, pull_request_id=pr1_id), { 'updaterev': '5ec21f21aafe95220f1fc4843a4a57c378498b71', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_REGULAR_LOGIN, + 'owner': base.TEST_USER_REGULAR_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), }, status=302) @@ -269,12 +269,12 @@ class TestPullrequestsController(TestCon # create PR 3 (new iteration with new ancestor) response = self.app.post( - url(controller='pullrequests', action='post', repo_name=HG_REPO, pull_request_id=pr2_id), + base.url(controller='pullrequests', action='post', repo_name=base.HG_REPO, pull_request_id=pr2_id), { 'updaterev': 'fb95b340e0d03fa51f33c56c991c08077c99303e', 'pullrequest_title': 'title', 'pullrequest_desc': 'description', - 'owner': TEST_USER_REGULAR_LOGIN, + 'owner': base.TEST_USER_REGULAR_LOGIN, '_session_csrf_secret_token': self.session_csrf_secret_token(), }, status=302) @@ -289,7 +289,7 @@ class TestPullrequestsController(TestCon @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods -class TestPullrequestsGetRepoRefs(TestController): +class TestPullrequestsGetRepoRefs(base.TestController): def setup_method(self, method): self.repo_name = u'main' diff --git a/kallithea/tests/functional/test_repo_groups.py b/kallithea/tests/functional/test_repo_groups.py --- a/kallithea/tests/functional/test_repo_groups.py +++ b/kallithea/tests/functional/test_repo_groups.py @@ -1,16 +1,16 @@ -from kallithea.tests.base import * +from kallithea.tests import base -class TestRepoGroupsController(TestController): +class TestRepoGroupsController(base.TestController): def test_index(self): self.log_user() - response = self.app.get(url('repos_groups')) + response = self.app.get(base.url('repos_groups')) response.mustcontain('"records": []') def test_new(self): self.log_user() - response = self.app.get(url('new_repos_group')) + response = self.app.get(base.url('new_repos_group')) def test_create(self): self.log_user() @@ -18,14 +18,14 @@ class TestRepoGroupsController(TestContr group_name = 'foo' # creation with form error - response = self.app.post(url('repos_groups'), + response = self.app.post(base.url('repos_groups'), {'group_name': group_name, '_session_csrf_secret_token': self.session_csrf_secret_token()}) response.mustcontain('name="group_name" type="text" value="%s"' % group_name) response.mustcontain('') # creation - response = self.app.post(url('repos_groups'), + response = self.app.post(base.url('repos_groups'), {'group_name': group_name, 'group_description': 'lala', 'parent_group_id': '-1', @@ -34,18 +34,18 @@ class TestRepoGroupsController(TestContr self.checkSessionFlash(response, 'Created repository group %s' % group_name) # edit form - response = self.app.get(url('edit_repo_group', group_name=group_name)) + response = self.app.get(base.url('edit_repo_group', group_name=group_name)) response.mustcontain('>lala<') # edit with form error - response = self.app.post(url('update_repos_group', group_name=group_name), + response = self.app.post(base.url('update_repos_group', group_name=group_name), {'group_name': group_name, '_session_csrf_secret_token': self.session_csrf_secret_token()}) response.mustcontain('name="group_name" type="text" value="%s"' % group_name) response.mustcontain('') # edit - response = self.app.post(url('update_repos_group', group_name=group_name), + response = self.app.post(base.url('update_repos_group', group_name=group_name), {'group_name': group_name, 'group_description': 'lolo', '_session_csrf_secret_token': self.session_csrf_secret_token()}) @@ -56,22 +56,22 @@ class TestRepoGroupsController(TestContr response.mustcontain('>lolo<') # listing - response = self.app.get(url('repos_groups')) + response = self.app.get(base.url('repos_groups')) response.mustcontain('raw_name": "%s"' % group_name) # show - response = self.app.get(url('repos_group', group_name=group_name)) + response = self.app.get(base.url('repos_group', group_name=group_name)) response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) # show ignores extra trailing slashes in the URL - response = self.app.get(url('repos_group', group_name='%s//' % group_name)) + response = self.app.get(base.url('repos_group', group_name='%s//' % group_name)) response.mustcontain('href="/_admin/repo_groups/%s/edit"' % group_name) # delete - response = self.app.post(url('delete_repo_group', group_name=group_name), + response = self.app.post(base.url('delete_repo_group', group_name=group_name), {'_session_csrf_secret_token': self.session_csrf_secret_token()}) self.checkSessionFlash(response, 'Removed repository group %s' % group_name) def test_new_by_regular_user(self): - self.log_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) - response = self.app.get(url('new_repos_group'), status=403) + self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS) + response = self.app.get(base.url('new_repos_group'), status=403) diff --git a/kallithea/tests/functional/test_search.py b/kallithea/tests/functional/test_search.py --- a/kallithea/tests/functional/test_search.py +++ b/kallithea/tests/functional/test_search.py @@ -1,13 +1,13 @@ import mock -from kallithea.tests.base import * +from kallithea.tests import base -class TestSearchController(TestController): +class TestSearchController(base.TestController): def test_index(self): self.log_user() - response = self.app.get(url(controller='search', action='index')) + response = self.app.get(base.url(controller='search', action='index')) response.mustcontain('class="form-control" id="q" name="q" type="text"') # Test response... @@ -20,33 +20,33 @@ class TestSearchController(TestControlle 'index_dir': str(tmpdir), } with mock.patch('kallithea.controllers.search.config', config_mock): - response = self.app.get(url(controller='search', action='index'), - {'q': HG_REPO}) + response = self.app.get(base.url(controller='search', action='index'), + {'q': base.HG_REPO}) response.mustcontain('The server has no search index.') def test_normal_search(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'def repo'}) response.mustcontain('58 results') def test_repo_search(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), - {'q': 'repository:%s def test' % HG_REPO}) + response = self.app.get(base.url(controller='search', action='index'), + {'q': 'repository:%s def test' % base.HG_REPO}) response.mustcontain('18 results') def test_search_last(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'last:t', 'type': 'commit'}) response.mustcontain('2 results') def test_search_commit_message(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'bother to ask where to fetch repo during tests', 'type': 'commit'}) @@ -56,8 +56,8 @@ class TestSearchController(TestControlle def test_search_commit_message_hg_repo(self): self.log_user() - response = self.app.get(url(controller='search', action='index', - repo_name=HG_REPO), + response = self.app.get(base.url(controller='search', action='index', + repo_name=base.HG_REPO), {'q': 'bother to ask where to fetch repo during tests', 'type': 'commit'}) @@ -66,7 +66,7 @@ class TestSearchController(TestControlle def test_search_commit_changed_file(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'changed:tests/utils.py', 'type': 'commit'}) @@ -74,7 +74,7 @@ class TestSearchController(TestControlle def test_search_commit_changed_files_get_commit(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'changed:vcs/utils/archivers.py', 'type': 'commit'}) @@ -90,7 +90,7 @@ class TestSearchController(TestControlle def test_search_commit_added_file(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'added:README.rst', 'type': 'commit'}) @@ -102,7 +102,7 @@ class TestSearchController(TestControlle def test_search_author(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545', 'type': 'commit'}) @@ -110,7 +110,7 @@ class TestSearchController(TestControlle def test_search_file_name(self): self.log_user() - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': 'README.rst', 'type': 'path'}) response.mustcontain('2 results') diff --git a/kallithea/tests/functional/test_search_indexing.py b/kallithea/tests/functional/test_search_indexing.py --- a/kallithea/tests/functional/test_search_indexing.py +++ b/kallithea/tests/functional/test_search_indexing.py @@ -5,7 +5,7 @@ from kallithea.config.conf import INDEX_ from kallithea.model.meta import Session from kallithea.model.repo import RepoModel from kallithea.model.repo_group import RepoGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture, create_test_index @@ -66,10 +66,10 @@ def rebuild_index(full_index): # (FYI, ENOMEM occurs at forking "git" with python 2.7.3, # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit # configuration for memory) - create_test_index(TESTS_TMP_PATH, CONFIG, full_index=full_index) + create_test_index(base.TESTS_TMP_PATH, CONFIG, full_index=full_index) -class TestSearchControllerIndexing(TestController): +class TestSearchControllerIndexing(base.TestController): @classmethod def setup_class(cls): for reponame, init_or_fork, groupname in repos: @@ -108,7 +108,7 @@ class TestSearchControllerIndexing(TestC rebuild_index(full_index=True) # rebuild fully for subsequent tests - @parametrize('reponame', [ + @base.parametrize('reponame', [ (u'indexing_test'), (u'indexing_test-fork'), (u'group/indexing_test'), @@ -116,7 +116,7 @@ class TestSearchControllerIndexing(TestC (u'*-fork'), (u'group/*'), ]) - @parametrize('searchtype,query,hit', [ + @base.parametrize('searchtype,query,hit', [ ('content', 'this_should_be_unique_content', 1), ('commit', 'this_should_be_unique_commit_log', 1), ('path', 'this_should_be_unique_filename.txt', 1), @@ -125,17 +125,17 @@ class TestSearchControllerIndexing(TestC self.log_user() q = 'repository:%s %s' % (reponame, query) - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': q, 'type': searchtype}) response.mustcontain('>%d results' % hit) - @parametrize('reponame', [ + @base.parametrize('reponame', [ (u'indexing_test'), (u'indexing_test-fork'), (u'group/indexing_test'), (u'this-is-it'), ]) - @parametrize('searchtype,query,hit', [ + @base.parametrize('searchtype,query,hit', [ ('content', 'this_should_be_unique_content', 1), ('commit', 'this_should_be_unique_commit_log', 1), ('path', 'this_should_be_unique_filename.txt', 1), @@ -143,12 +143,12 @@ class TestSearchControllerIndexing(TestC def test_searching_under_repository(self, reponame, searchtype, query, hit): self.log_user() - response = self.app.get(url(controller='search', action='index', + response = self.app.get(base.url(controller='search', action='index', repo_name=reponame), {'q': query, 'type': searchtype}) response.mustcontain('>%d results' % hit) - @parametrize('searchtype,query,hit', [ + @base.parametrize('searchtype,query,hit', [ ('content', 'path:this/is/it def test', 1), ('commit', 'added:this/is/it bother to ask where', 1), # this condition matches against files below, because @@ -161,12 +161,12 @@ class TestSearchControllerIndexing(TestC ('path', 'extension:us', 1), ]) def test_filename_stopword(self, searchtype, query, hit): - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': query, 'type': searchtype}) response.mustcontain('>%d results' % hit) - @parametrize('searchtype,query,hit', [ + @base.parametrize('searchtype,query,hit', [ # matching against both 2 files ('content', 'owner:"this is it"', 0), ('content', 'owner:this-is-it', 0), @@ -182,7 +182,7 @@ class TestSearchControllerIndexing(TestC ('commit', 'author:"this-is-it"', 1), ]) def test_mailaddr_stopword(self, searchtype, query, hit): - response = self.app.get(url(controller='search', action='index'), + response = self.app.get(base.url(controller='search', action='index'), {'q': query, 'type': searchtype}) response.mustcontain('>%d results' % hit) diff --git a/kallithea/tests/functional/test_summary.py b/kallithea/tests/functional/test_summary.py --- a/kallithea/tests/functional/test_summary.py +++ b/kallithea/tests/functional/test_summary.py @@ -18,7 +18,7 @@ from kallithea.model.db import Repositor from kallithea.model.meta import Session from kallithea.model.repo import RepoModel from kallithea.model.scm import ScmModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture @@ -32,14 +32,14 @@ def custom_settings(set_test_settings): ) -class TestSummaryController(TestController): +class TestSummaryController(base.TestController): def test_index_hg(self, custom_settings): self.log_user() - ID = Repository.get_by_repo_name(HG_REPO).repo_id - response = self.app.get(url(controller='summary', + ID = Repository.get_by_repo_name(base.HG_REPO).repo_id + response = self.app.get(base.url(controller='summary', action='index', - repo_name=HG_REPO)) + repo_name=base.HG_REPO)) # repo type response.mustcontain( @@ -52,24 +52,24 @@ class TestSummaryController(TestControll # clone URLs response.mustcontain( '''''' % - (TEST_USER_ADMIN_LOGIN, HG_REPO) + (base.TEST_USER_ADMIN_LOGIN, base.HG_REPO) ) response.mustcontain( '''''' % - (TEST_USER_ADMIN_LOGIN, ID) + (base.TEST_USER_ADMIN_LOGIN, ID) ) response.mustcontain( '''''' % - (HG_REPO) + (base.HG_REPO) ) def test_index_git(self, custom_settings): self.log_user() - ID = Repository.get_by_repo_name(GIT_REPO).repo_id - response = self.app.get(url(controller='summary', + ID = Repository.get_by_repo_name(base.GIT_REPO).repo_id + response = self.app.get(base.url(controller='summary', action='index', - repo_name=GIT_REPO)) + repo_name=base.GIT_REPO)) # repo type response.mustcontain( @@ -82,21 +82,21 @@ class TestSummaryController(TestControll # clone URLs response.mustcontain( '''''' % - (TEST_USER_ADMIN_LOGIN, GIT_REPO) + (base.TEST_USER_ADMIN_LOGIN, base.GIT_REPO) ) response.mustcontain( '''''' % - (TEST_USER_ADMIN_LOGIN, ID) + (base.TEST_USER_ADMIN_LOGIN, ID) ) response.mustcontain( '''''' % - (GIT_REPO) + (base.GIT_REPO) ) def test_index_by_id_hg(self): self.log_user() - ID = Repository.get_by_repo_name(HG_REPO).repo_id - response = self.app.get(url(controller='summary', + ID = Repository.get_by_repo_name(base.HG_REPO).repo_id + response = self.app.get(base.url(controller='summary', action='index', repo_name='_%s' % ID)) @@ -112,7 +112,7 @@ class TestSummaryController(TestControll def test_index_by_repo_having_id_path_in_name_hg(self): self.log_user() fixture.create_repo(name=u'repo_1') - response = self.app.get(url(controller='summary', + response = self.app.get(base.url(controller='summary', action='index', repo_name='repo_1')) @@ -124,8 +124,8 @@ class TestSummaryController(TestControll def test_index_by_id_git(self): self.log_user() - ID = Repository.get_by_repo_name(GIT_REPO).repo_id - response = self.app.get(url(controller='summary', + ID = Repository.get_by_repo_name(base.GIT_REPO).repo_id + response = self.app.get(base.url(controller='summary', action='index', repo_name='_%s' % ID)) @@ -146,14 +146,14 @@ class TestSummaryController(TestControll def test_index_trending(self): self.log_user() # codes stats - self._enable_stats(HG_REPO) + self._enable_stats(base.HG_REPO) - ScmModel().mark_for_invalidation(HG_REPO) + ScmModel().mark_for_invalidation(base.HG_REPO) # generate statistics first - response = self.app.get(url(controller='summary', action='statistics', - repo_name=HG_REPO)) - response = self.app.get(url(controller='summary', action='index', - repo_name=HG_REPO)) + response = self.app.get(base.url(controller='summary', action='statistics', + repo_name=base.HG_REPO)) + response = self.app.get(base.url(controller='summary', action='index', + repo_name=base.HG_REPO)) response.mustcontain( '[["py", {"count": 68, "desc": ["Python"]}], ' '["rst", {"count": 16, "desc": ["Rst"]}], ' @@ -170,23 +170,23 @@ class TestSummaryController(TestControll def test_index_statistics(self): self.log_user() # codes stats - self._enable_stats(HG_REPO) + self._enable_stats(base.HG_REPO) - ScmModel().mark_for_invalidation(HG_REPO) - response = self.app.get(url(controller='summary', action='statistics', - repo_name=HG_REPO)) + ScmModel().mark_for_invalidation(base.HG_REPO) + response = self.app.get(base.url(controller='summary', action='statistics', + repo_name=base.HG_REPO)) def test_index_trending_git(self): self.log_user() # codes stats - self._enable_stats(GIT_REPO) + self._enable_stats(base.GIT_REPO) - ScmModel().mark_for_invalidation(GIT_REPO) + ScmModel().mark_for_invalidation(base.GIT_REPO) # generate statistics first - response = self.app.get(url(controller='summary', action='statistics', - repo_name=GIT_REPO)) - response = self.app.get(url(controller='summary', action='index', - repo_name=GIT_REPO)) + response = self.app.get(base.url(controller='summary', action='statistics', + repo_name=base.GIT_REPO)) + response = self.app.get(base.url(controller='summary', action='index', + repo_name=base.GIT_REPO)) response.mustcontain( '[["py", {"count": 68, "desc": ["Python"]}], ' '["rst", {"count": 16, "desc": ["Rst"]}], ' @@ -203,8 +203,8 @@ class TestSummaryController(TestControll def test_index_statistics_git(self): self.log_user() # codes stats - self._enable_stats(GIT_REPO) + self._enable_stats(base.GIT_REPO) - ScmModel().mark_for_invalidation(GIT_REPO) - response = self.app.get(url(controller='summary', action='statistics', - repo_name=GIT_REPO)) + ScmModel().mark_for_invalidation(base.GIT_REPO) + response = self.app.get(base.url(controller='summary', action='statistics', + repo_name=base.GIT_REPO)) diff --git a/kallithea/tests/models/test_changeset_status.py b/kallithea/tests/models/test_changeset_status.py --- a/kallithea/tests/models/test_changeset_status.py +++ b/kallithea/tests/models/test_changeset_status.py @@ -1,6 +1,6 @@ from kallithea.model.changeset_status import ChangesetStatusModel from kallithea.model.db import ChangesetStatus as CS -from kallithea.tests.base import * +from kallithea.tests import base class CSM(object): # ChangesetStatusMock @@ -9,12 +9,12 @@ class CSM(object): # ChangesetStatusMock self.status = status -class TestChangesetStatusCalculation(TestController): +class TestChangesetStatusCalculation(base.TestController): def setup_method(self, method): self.m = ChangesetStatusModel() - @parametrize('name,expected_result,statuses', [ + @base.parametrize('name,expected_result,statuses', [ ('empty list', CS.STATUS_UNDER_REVIEW, []), ('approve', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED)]), ('approve2', CS.STATUS_APPROVED, [CSM(CS.STATUS_APPROVED), CSM(CS.STATUS_APPROVED)]), diff --git a/kallithea/tests/models/test_comments.py b/kallithea/tests/models/test_comments.py --- a/kallithea/tests/models/test_comments.py +++ b/kallithea/tests/models/test_comments.py @@ -3,10 +3,10 @@ from tg.util.webtest import test_context from kallithea.model.comment import ChangesetCommentsModel from kallithea.model.db import Repository -from kallithea.tests.base import * +from kallithea.tests import base -class TestComments(TestController): +class TestComments(base.TestController): def _check_comment_count(self, repo_id, revision, expected_len_comments, expected_len_inline_comments, @@ -23,7 +23,7 @@ class TestComments(TestController): def test_create_delete_general_comment(self): with test_context(self.app): - repo_id = Repository.get_by_repo_name(HG_REPO).repo_id + repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' self._check_comment_count(repo_id, revision, @@ -32,8 +32,8 @@ class TestComments(TestController): text = u'a comment' new_comment = ChangesetCommentsModel().create( text=text, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, send_email=False) @@ -47,7 +47,7 @@ class TestComments(TestController): def test_create_delete_inline_comment(self): with test_context(self.app): - repo_id = Repository.get_by_repo_name(HG_REPO).repo_id + repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' self._check_comment_count(repo_id, revision, @@ -58,8 +58,8 @@ class TestComments(TestController): line_no = u'n50' new_comment = ChangesetCommentsModel().create( text=text, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path, line_no=line_no, @@ -81,7 +81,7 @@ class TestComments(TestController): def test_create_delete_multiple_inline_comments(self): with test_context(self.app): - repo_id = Repository.get_by_repo_name(HG_REPO).repo_id + repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' self._check_comment_count(repo_id, revision, @@ -92,8 +92,8 @@ class TestComments(TestController): line_no = u'n50' new_comment = ChangesetCommentsModel().create( text=text, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path, line_no=line_no, @@ -103,8 +103,8 @@ class TestComments(TestController): line_no2 = u'o41' new_comment2 = ChangesetCommentsModel().create( text=text2, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path, line_no=line_no2, @@ -115,8 +115,8 @@ class TestComments(TestController): line_no3 = u'n159' new_comment3 = ChangesetCommentsModel().create( text=text3, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path3, line_no=line_no3, @@ -161,7 +161,7 @@ class TestComments(TestController): def test_selective_retrieval_of_inline_comments(self): with test_context(self.app): - repo_id = Repository.get_by_repo_name(HG_REPO).repo_id + repo_id = Repository.get_by_repo_name(base.HG_REPO).repo_id revision = '9a7b4ff9e8b40bbda72fc75f162325b9baa45cda' self._check_comment_count(repo_id, revision, @@ -172,8 +172,8 @@ class TestComments(TestController): line_no = u'n50' new_comment = ChangesetCommentsModel().create( text=text, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path, line_no=line_no, @@ -183,8 +183,8 @@ class TestComments(TestController): line_no2 = u'o41' new_comment2 = ChangesetCommentsModel().create( text=text2, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path, line_no=line_no2, @@ -195,8 +195,8 @@ class TestComments(TestController): line_no3 = u'n159' new_comment3 = ChangesetCommentsModel().create( text=text3, - repo=HG_REPO, - author=TEST_USER_REGULAR_LOGIN, + repo=base.HG_REPO, + author=base.TEST_USER_REGULAR_LOGIN, revision=revision, f_path=f_path3, line_no=line_no3, diff --git a/kallithea/tests/models/test_diff_parsers.py b/kallithea/tests/models/test_diff_parsers.py --- a/kallithea/tests/models/test_diff_parsers.py +++ b/kallithea/tests/models/test_diff_parsers.py @@ -1,5 +1,5 @@ from kallithea.lib.diffs import BIN_FILENODE, CHMOD_FILENODE, COPIED_FILENODE, DEL_FILENODE, MOD_FILENODE, NEW_FILENODE, RENAMED_FILENODE, DiffProcessor -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture @@ -271,9 +271,9 @@ DIFF_FIXTURES = { } -class TestDiffLib(TestController): +class TestDiffLib(base.TestController): - @parametrize('diff_fixture', DIFF_FIXTURES) + @base.parametrize('diff_fixture', DIFF_FIXTURES) def test_diff(self, diff_fixture): raw_diff = fixture.load_resource(diff_fixture, strip=False) vcs = 'hg' diff --git a/kallithea/tests/models/test_notifications.py b/kallithea/tests/models/test_notifications.py --- a/kallithea/tests/models/test_notifications.py +++ b/kallithea/tests/models/test_notifications.py @@ -11,10 +11,10 @@ from kallithea.model.db import User from kallithea.model.meta import Session from kallithea.model.notification import EmailNotificationModel, NotificationModel from kallithea.model.user import UserModel -from kallithea.tests.base import * +from kallithea.tests import base -class TestNotifications(TestController): +class TestNotifications(base.TestController): def setup_method(self, method): Session.remove() diff --git a/kallithea/tests/models/test_permissions.py b/kallithea/tests/models/test_permissions.py --- a/kallithea/tests/models/test_permissions.py +++ b/kallithea/tests/models/test_permissions.py @@ -6,14 +6,14 @@ from kallithea.model.repo import RepoMod from kallithea.model.repo_group import RepoGroupModel from kallithea.model.user import UserModel from kallithea.model.user_group import UserGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestPermissions(TestController): +class TestPermissions(base.TestController): @classmethod def setup_class(cls): @@ -71,33 +71,33 @@ class TestPermissions(TestController): 'repositories_groups': {}, 'global': set(['hg.create.repository', 'repository.read', 'hg.register.manual_activate']), - 'repositories': {HG_REPO: 'repository.read'} + 'repositories': {base.HG_REPO: 'repository.read'} } - assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] + assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] new_perm = 'repository.write' - RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, + RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, perm=new_perm) Session().commit() u1_auth = AuthUser(user_id=self.u1.user_id) - assert u1_auth.permissions['repositories'][HG_REPO] == new_perm + assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm def test_default_admin_perms_set(self): a1_auth = AuthUser(user_id=self.a1.user_id) perms = { 'repositories_groups': {}, 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), - 'repositories': {HG_REPO: 'repository.admin'} + 'repositories': {base.HG_REPO: 'repository.admin'} } - assert a1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] + assert a1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] new_perm = 'repository.write' - RepoModel().grant_user_permission(repo=HG_REPO, user=self.a1, + RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.a1, perm=new_perm) Session().commit() # cannot really downgrade admins permissions !? they still gets set as # admin ! u1_auth = AuthUser(user_id=self.a1.user_id) - assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] + assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] def test_default_group_perms(self): self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) @@ -106,9 +106,9 @@ class TestPermissions(TestController): perms = { 'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'}, 'global': set(Permission.DEFAULT_USER_PERMISSIONS), - 'repositories': {HG_REPO: 'repository.read'} + 'repositories': {base.HG_REPO: 'repository.read'} } - assert u1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] + assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] assert u1_auth.permissions['global'] == perms['global'] @@ -119,10 +119,10 @@ class TestPermissions(TestController): perms = { 'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'}, 'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']), - 'repositories': {HG_REPO: 'repository.admin'} + 'repositories': {base.HG_REPO: 'repository.admin'} } - assert a1_auth.permissions['repositories'][HG_REPO] == perms['repositories'][HG_REPO] + assert a1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO] assert a1_auth.permissions['repositories_groups'] == perms['repositories_groups'] def test_propagated_permission_from_users_group_by_explicit_perms_exist(self): @@ -131,19 +131,19 @@ class TestPermissions(TestController): UserGroupModel().add_user_to_group(self.ug1, self.u1) # set user permission none - RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, perm='repository.none') + RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, perm='repository.none') Session().commit() u1_auth = AuthUser(user_id=self.u1.user_id) - assert u1_auth.permissions['repositories'][HG_REPO] == 'repository.read' # inherit from default user + assert u1_auth.permissions['repositories'][base.HG_REPO] == 'repository.read' # inherit from default user # grant perm for group this should override permission from user - RepoModel().grant_user_group_permission(repo=HG_REPO, + RepoModel().grant_user_group_permission(repo=base.HG_REPO, group_name=self.ug1, perm='repository.write') # verify that user group permissions win u1_auth = AuthUser(user_id=self.u1.user_id) - assert u1_auth.permissions['repositories'][HG_REPO] == 'repository.write' + assert u1_auth.permissions['repositories'][base.HG_REPO] == 'repository.write' def test_propagated_permission_from_users_group(self): # make group @@ -152,7 +152,7 @@ class TestPermissions(TestController): # grant perm for group this should override default permission from user new_perm_gr = 'repository.write' - RepoModel().grant_user_group_permission(repo=HG_REPO, + RepoModel().grant_user_group_permission(repo=base.HG_REPO, group_name=self.ug1, perm=new_perm_gr) # check perms @@ -161,9 +161,9 @@ class TestPermissions(TestController): 'repositories_groups': {}, 'global': set(['hg.create.repository', 'repository.read', 'hg.register.manual_activate']), - 'repositories': {HG_REPO: 'repository.read'} + 'repositories': {base.HG_REPO: 'repository.read'} } - assert u3_auth.permissions['repositories'][HG_REPO] == new_perm_gr + assert u3_auth.permissions['repositories'][base.HG_REPO] == new_perm_gr assert u3_auth.permissions['repositories_groups'] == perms['repositories_groups'] def test_propagated_permission_from_users_group_lower_weight(self): @@ -174,16 +174,16 @@ class TestPermissions(TestController): # set permission to lower new_perm_h = 'repository.write' - RepoModel().grant_user_permission(repo=HG_REPO, user=self.u1, + RepoModel().grant_user_permission(repo=base.HG_REPO, user=self.u1, perm=new_perm_h) Session().commit() u1_auth = AuthUser(user_id=self.u1.user_id) - assert u1_auth.permissions['repositories'][HG_REPO] == new_perm_h + assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm_h # grant perm for group this should NOT override permission from user # since it's lower than granted new_perm_l = 'repository.read' - RepoModel().grant_user_group_permission(repo=HG_REPO, + RepoModel().grant_user_group_permission(repo=base.HG_REPO, group_name=self.ug1, perm=new_perm_l) # check perms @@ -192,9 +192,9 @@ class TestPermissions(TestController): 'repositories_groups': {}, 'global': set(['hg.create.repository', 'repository.read', 'hg.register.manual_activate']), - 'repositories': {HG_REPO: 'repository.write'} + 'repositories': {base.HG_REPO: 'repository.write'} } - assert u1_auth.permissions['repositories'][HG_REPO] == new_perm_h + assert u1_auth.permissions['repositories'][base.HG_REPO] == new_perm_h assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups'] def test_repo_in_group_permissions(self): @@ -641,7 +641,7 @@ class TestPermissions(TestController): PermissionModel().create_default_permissions(user=self.u1) self._test_def_perm_equal(user=self.u1) - @parametrize('perm,modify_to', [ + @base.parametrize('perm,modify_to', [ ('repository.read', 'repository.none'), ('group.read', 'group.none'), ('usergroup.read', 'usergroup.none'), diff --git a/kallithea/tests/models/test_repo_groups.py b/kallithea/tests/models/test_repo_groups.py --- a/kallithea/tests/models/test_repo_groups.py +++ b/kallithea/tests/models/test_repo_groups.py @@ -7,7 +7,7 @@ from kallithea.model.db import RepoGroup from kallithea.model.meta import Session from kallithea.model.repo import RepoModel from kallithea.model.repo_group import RepoGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture @@ -34,7 +34,7 @@ def _update_repo(name, **kwargs): return r -class TestRepoGroups(TestController): +class TestRepoGroups(base.TestController): def setup_method(self, method): self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True) @@ -48,7 +48,7 @@ class TestRepoGroups(TestController): """ Checks the path for existence ! """ - path = [TESTS_TMP_PATH] + list(path) + path = [base.TESTS_TMP_PATH] + list(path) path = os.path.join(*path) return os.path.isdir(path) diff --git a/kallithea/tests/models/test_repos.py b/kallithea/tests/models/test_repos.py --- a/kallithea/tests/models/test_repos.py +++ b/kallithea/tests/models/test_repos.py @@ -4,14 +4,14 @@ from kallithea.lib.exceptions import Att from kallithea.model.db import Repository from kallithea.model.meta import Session from kallithea.model.repo import RepoModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestRepos(TestController): +class TestRepos(base.TestController): def teardown_method(self, method): Session.remove() diff --git a/kallithea/tests/models/test_user_groups.py b/kallithea/tests/models/test_user_groups.py --- a/kallithea/tests/models/test_user_groups.py +++ b/kallithea/tests/models/test_user_groups.py @@ -1,14 +1,14 @@ from kallithea.model.db import User, UserGroup from kallithea.model.meta import Session from kallithea.model.user_group import UserGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestUserGroups(TestController): +class TestUserGroups(base.TestController): def teardown_method(self, method): # delete all groups @@ -16,7 +16,7 @@ class TestUserGroups(TestController): fixture.destroy_user_group(gr) Session().commit() - @parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ + @base.parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [ ([], [], [], [], []), ([], [u'regular'], [], [], [u'regular']), # no changes of regular ([u'some_other'], [], [], [u'some_other'], []), # not added to regular group @@ -32,7 +32,7 @@ class TestUserGroups(TestController): fixture.destroy_user_group(gr) Session().commit() - user = User.get_by_username(TEST_USER_REGULAR_LOGIN) + user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) for gr in pre_existing: gr = fixture.create_user_group(gr) Session().commit() @@ -54,6 +54,6 @@ class TestUserGroups(TestController): UserGroupModel().enforce_groups(user, groups, 'container') Session().commit() - user = User.get_by_username(TEST_USER_REGULAR_LOGIN) + user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) in_groups = user.group_member assert sorted(expected) == sorted(x.users_group.users_group_name for x in in_groups) diff --git a/kallithea/tests/models/test_users.py b/kallithea/tests/models/test_users.py --- a/kallithea/tests/models/test_users.py +++ b/kallithea/tests/models/test_users.py @@ -4,14 +4,14 @@ from kallithea.model.db import Permissio from kallithea.model.meta import Session from kallithea.model.user import UserModel from kallithea.model.user_group import UserGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture fixture = Fixture() -class TestUser(TestController): +class TestUser(base.TestController): @classmethod def setup_class(cls): @@ -101,7 +101,7 @@ class TestUser(TestController): Session().commit() -class TestUsers(TestController): +class TestUsers(base.TestController): def setup_method(self, method): self.u1 = UserModel().create_or_update(username=u'u1', diff --git a/kallithea/tests/other/test_libs.py b/kallithea/tests/other/test_libs.py --- a/kallithea/tests/other/test_libs.py +++ b/kallithea/tests/other/test_libs.py @@ -33,7 +33,7 @@ from tg.util.webtest import test_context from kallithea.lib.utils2 import AttributeDict from kallithea.model.db import Repository -from kallithea.tests.base import * +from kallithea.tests import base proto = 'http' @@ -91,19 +91,19 @@ class FakeUrlGenerator(object): return self.current_url % kwargs -class TestLibs(TestController): +class TestLibs(base.TestController): - @parametrize('test_url,expected,expected_creds', TEST_URLS) + @base.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 assert uri_filter(test_url) == expected - @parametrize('test_url,expected,expected_creds', TEST_URLS) + @base.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 assert credentials_filter(test_url) == expected_creds - @parametrize('str_bool,expected', [ + @base.parametrize('str_bool,expected', [ ('t', True), ('true', True), ('y', True), @@ -141,7 +141,7 @@ class TestLibs(TestController): 'marian.user', 'marco-polo', 'marco_polo', 'world']) assert expected == set(extract_mentioned_usernames(sample)) - @parametrize('age_args,expected', [ + @base.parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds= -1), u'1 second ago'), (dict(seconds= -60 * 2), u'2 minutes ago'), @@ -165,7 +165,7 @@ class TestLibs(TestController): delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) assert age(n + delt(**age_args), now=n) == expected - @parametrize('age_args,expected', [ + @base.parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds= -1), u'1 second ago'), (dict(seconds= -60 * 2), u'2 minutes ago'), @@ -190,7 +190,7 @@ class TestLibs(TestController): delt = lambda *args, **kwargs: relativedelta.relativedelta(*args, **kwargs) assert age(n + delt(**age_args), show_short_version=True, now=n) == expected - @parametrize('age_args,expected', [ + @base.parametrize('age_args,expected', [ (dict(), u'just now'), (dict(seconds=1), u'in 1 second'), (dict(seconds=60 * 2), u'in 2 minutes'), @@ -270,7 +270,7 @@ class TestLibs(TestController): grav = gravatar_url(email_address=em, size=24) assert grav == 'https://example.com/%s/%s' % (_md5(em), 24) - @parametrize('clone_uri_tmpl,repo_name,username,prefix,expected', [ + @base.parametrize('clone_uri_tmpl,repo_name,username,prefix,expected', [ (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '', 'http://vps1:8000/group/repo1'), (Repository.DEFAULT_CLONE_URI, 'group/repo1', 'username', '', 'http://username@vps1:8000/group/repo1'), (Repository.DEFAULT_CLONE_URI, 'group/repo1', None, '/prefix', 'http://vps1:8000/prefix/group/repo1'), @@ -307,7 +307,7 @@ class TestLibs(TestController): return tmpl % (url_ or '/repo_name/changeset/%s' % _url, _url) return url_pattern.sub(url_func, text) - @parametrize('sample,expected', [ + @base.parametrize('sample,expected', [ ("", ""), ("git-svn-id: https://svn.apache.org/repos/asf/libcloud/trunk@1441655 13f79535-47bb-0310-9956-ffa450edef68", @@ -341,7 +341,7 @@ class TestLibs(TestController): from kallithea.lib.helpers import urlify_text assert urlify_text(sample, 'repo_name') == expected - @parametrize('sample,expected,url_', [ + @base.parametrize('sample,expected,url_', [ ("", "", ""), @@ -396,7 +396,7 @@ class TestLibs(TestController): from kallithea.lib.helpers import urlify_text assert urlify_text(sample, 'repo_name', stylize=True) == expected - @parametrize('sample,expected', [ + @base.parametrize('sample,expected', [ ("deadbeefcafe @mention, and http://foo.bar/ yo", """deadbeefcafe""" """""" @@ -409,7 +409,7 @@ class TestLibs(TestController): from kallithea.lib.helpers import urlify_text assert urlify_text(sample, 'repo_name', link_='#the-link') == expected - @parametrize('issue_pat,issue_server,issue_sub,sample,expected', [ + @base.parametrize('issue_pat,issue_server,issue_sub,sample,expected', [ (r'#(\d+)', 'http://foo/{repo}/issue/\\1', '#\\1', 'issue #123 and issue#456', """issue #123 and """ @@ -500,7 +500,7 @@ class TestLibs(TestController): with mock.patch('kallithea.CONFIG', config_stub): assert urlify_text(sample, 'repo_name') == expected - @parametrize('sample,expected', [ + @base.parametrize('sample,expected', [ ('abc X5', 'abc #5'), ('abc pullrequest #6 xyz', 'abc PR#6 xyz'), ('pull request7 #', 'PR#7 #'), @@ -533,7 +533,7 @@ class TestLibs(TestController): with mock.patch('kallithea.CONFIG', config_stub): assert urlify_text(sample, 'repo_name') == expected - @parametrize('test,expected', [ + @base.parametrize('test,expected', [ ("", None), ("/_2", None), ("_2", 2), @@ -542,9 +542,9 @@ class TestLibs(TestController): def test_get_permanent_id(self, test, expected): from kallithea.lib.utils import _get_permanent_id extracted = _get_permanent_id(test) - assert extracted == expected, 'url:%s, got:`%s` expected: `%s`' % (test, _test, expected) + assert extracted == expected, 'url:%s, got:`%s` expected: `%s`' % (test, base._test, expected) - @parametrize('test,expected', [ + @base.parametrize('test,expected', [ ("", ""), ("/", "/"), ("/_ID", '/_ID'), @@ -555,14 +555,14 @@ class TestLibs(TestController): ("_IDa", '_IDa'), ]) def test_fix_repo_id_name(self, test, expected): - repo = Repository.get_by_repo_name(HG_REPO) + repo = Repository.get_by_repo_name(base.HG_REPO) test = test.replace('ID', str(repo.repo_id)) expected = expected.replace('NAME', repo.repo_name).replace('ID', str(repo.repo_id)) from kallithea.lib.utils import fix_repo_id_name replaced = fix_repo_id_name(test) assert replaced == expected, 'url:%s, got:`%s` expected: `%s`' % (test, replaced, expected) - @parametrize('canonical,test,expected', [ + @base.parametrize('canonical,test,expected', [ ('http://www.example.org/', '/abc/xyz', 'http://www.example.org/abc/xyz'), ('http://www.example.org', '/abc/xyz', 'http://www.example.org/abc/xyz'), ('http://www.example.org', '/abc/xyz/', 'http://www.example.org/abc/xyz/'), @@ -590,7 +590,7 @@ class TestLibs(TestController): with mock.patch('kallithea.CONFIG', config_mock): assert canonical_url(test) == expected - @parametrize('canonical,expected', [ + @base.parametrize('canonical,expected', [ ('http://www.example.org', 'www.example.org'), ('http://www.example.org/repos/', 'www.example.org'), ('http://www.example.org/kallithea/repos/', 'www.example.org'), diff --git a/kallithea/tests/other/test_mail.py b/kallithea/tests/other/test_mail.py --- a/kallithea/tests/other/test_mail.py +++ b/kallithea/tests/other/test_mail.py @@ -2,7 +2,7 @@ import mock import kallithea from kallithea.model.db import User -from kallithea.tests.base import * +from kallithea.tests import base class smtplib_mock(object): @@ -25,7 +25,7 @@ class smtplib_mock(object): @mock.patch('kallithea.lib.rcmail.smtp_mailer.smtplib', smtplib_mock) -class TestMail(TestController): +class TestMail(base.TestController): def test_send_mail_trivial(self): mailserver = 'smtp.mailserver.org' @@ -66,7 +66,7 @@ class TestMail(TestController): with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) - assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL, email_to]) + assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL, email_to]) assert smtplib_mock.lastsender == envelope_from assert 'From: %s' % envelope_from in smtplib_mock.lastmsg assert 'Subject: %s' % subject in smtplib_mock.lastmsg @@ -90,7 +90,7 @@ class TestMail(TestController): with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) - assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL] + email_to.split(',')) + assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL] + email_to.split(',')) assert smtplib_mock.lastsender == envelope_from assert 'From: %s' % envelope_from in smtplib_mock.lastmsg assert 'Subject: %s' % subject in smtplib_mock.lastmsg @@ -112,7 +112,7 @@ class TestMail(TestController): with mock.patch('kallithea.lib.celerylib.tasks.config', config_mock): kallithea.lib.celerylib.tasks.send_email(recipients, subject, body, html_body) - assert smtplib_mock.lastdest == set([TEST_USER_ADMIN_EMAIL]) + assert smtplib_mock.lastdest == set([base.TEST_USER_ADMIN_EMAIL]) assert smtplib_mock.lastsender == envelope_from assert 'From: %s' % envelope_from in smtplib_mock.lastmsg assert 'Subject: %s' % subject in smtplib_mock.lastmsg @@ -126,7 +126,7 @@ class TestMail(TestController): subject = 'subject' body = 'body' html_body = 'html_body' - author = User.get_by_username(TEST_USER_REGULAR_LOGIN) + author = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) config_mock = { 'smtp_server': mailserver, @@ -150,7 +150,7 @@ class TestMail(TestController): subject = 'subject' body = 'body' html_body = 'html_body' - author = User.get_by_username(TEST_USER_REGULAR_LOGIN) + author = User.get_by_username(base.TEST_USER_REGULAR_LOGIN) config_mock = { 'smtp_server': mailserver, diff --git a/kallithea/tests/other/test_validators.py b/kallithea/tests/other/test_validators.py --- a/kallithea/tests/other/test_validators.py +++ b/kallithea/tests/other/test_validators.py @@ -6,7 +6,7 @@ from kallithea.model import validators a from kallithea.model.meta import Session from kallithea.model.repo_group import RepoGroupModel from kallithea.model.user_group import UserGroupModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture @@ -14,7 +14,7 @@ fixture = Fixture() @pytest.mark.usefixtures("test_context_fixture") # apply fixture for all test methods -class TestRepoGroups(TestController): +class TestRepoGroups(base.TestController): def teardown_method(self, method): Session.remove() @@ -40,7 +40,7 @@ class TestRepoGroups(TestController): with pytest.raises(formencode.Invalid): validator.to_python('.,') with pytest.raises(formencode.Invalid): - validator.to_python(TEST_USER_ADMIN_LOGIN) + validator.to_python(base.TEST_USER_ADMIN_LOGIN) assert 'test' == validator.to_python('test') validator = v.ValidUsername(edit=True, old_data={'user_id': 1}) @@ -49,7 +49,7 @@ class TestRepoGroups(TestController): validator = v.ValidRepoUser() with pytest.raises(formencode.Invalid): validator.to_python('nouser') - assert TEST_USER_ADMIN_LOGIN == validator.to_python(TEST_USER_ADMIN_LOGIN) + assert base.TEST_USER_ADMIN_LOGIN == validator.to_python(base.TEST_USER_ADMIN_LOGIN) def test_ValidUserGroup(self): validator = v.ValidUserGroup() @@ -82,11 +82,11 @@ class TestRepoGroups(TestController): validator = v.ValidRepoGroup() model = RepoGroupModel() with pytest.raises(formencode.Invalid): - validator.to_python({'group_name': HG_REPO, }) + validator.to_python({'group_name': base.HG_REPO, }) gr = model.create(group_name=u'test_gr', group_description=u'desc', parent=None, just_db=True, - owner=TEST_USER_ADMIN_LOGIN) + owner=base.TEST_USER_ADMIN_LOGIN) with pytest.raises(formencode.Invalid): validator.to_python({'group_name': gr.group_name, }) @@ -127,8 +127,8 @@ class TestRepoGroups(TestController): def test_ValidAuth(self): validator = v.ValidAuth() valid_creds = { - 'username': TEST_USER_REGULAR2_LOGIN, - 'password': TEST_USER_REGULAR2_PASS, + 'username': base.TEST_USER_REGULAR2_LOGIN, + 'password': base.TEST_USER_REGULAR2_PASS, } invalid_creds = { 'username': 'err', @@ -145,12 +145,12 @@ class TestRepoGroups(TestController): validator.to_python({'repo_name': ''}) with pytest.raises(formencode.Invalid): - validator.to_python({'repo_name': HG_REPO}) + validator.to_python({'repo_name': base.HG_REPO}) gr = RepoGroupModel().create(group_name=u'group_test', group_description=u'desc', parent=None, - owner=TEST_USER_ADMIN_LOGIN) + owner=base.TEST_USER_ADMIN_LOGIN) with pytest.raises(formencode.Invalid): validator.to_python({'repo_name': gr.group_name}) @@ -163,7 +163,7 @@ class TestRepoGroups(TestController): # this uses ValidRepoName validator assert True - @parametrize('name,expected', [ + @base.parametrize('name,expected', [ ('test', 'test'), ('lolz!', 'lolz'), (' aavv', 'aavv'), ('ala ma kota', 'ala-ma-kota'), ('@nooo', 'nooo'), ('$!haha lolz !', 'haha-lolz'), ('$$$$$', ''), ('{}OK!', 'OK'), @@ -196,7 +196,7 @@ class TestRepoGroups(TestController): def test_ValidPath(self): validator = v.ValidPath() - assert TESTS_TMP_PATH == validator.to_python(TESTS_TMP_PATH) + assert base.TESTS_TMP_PATH == validator.to_python(base.TESTS_TMP_PATH) with pytest.raises(formencode.Invalid): validator.to_python('/no_such_dir') @@ -205,20 +205,20 @@ class TestRepoGroups(TestController): assert 'mail@python.org' == validator.to_python('MaiL@Python.org') - email = TEST_USER_REGULAR2_EMAIL + email = base.TEST_USER_REGULAR2_EMAIL with pytest.raises(formencode.Invalid): validator.to_python(email) def test_ValidSystemEmail(self): validator = v.ValidSystemEmail() - email = TEST_USER_REGULAR2_EMAIL + email = base.TEST_USER_REGULAR2_EMAIL assert email == validator.to_python(email) with pytest.raises(formencode.Invalid): validator.to_python('err') def test_LdapLibValidator(self): - if ldap_lib_installed: + if base.ldap_lib_installed: validator = v.LdapLibValidator() assert "DN" == validator.to_python('DN') else: diff --git a/kallithea/tests/other/test_vcs_operations.py b/kallithea/tests/other/test_vcs_operations.py --- a/kallithea/tests/other/test_vcs_operations.py +++ b/kallithea/tests/other/test_vcs_operations.py @@ -44,7 +44,7 @@ from kallithea.model.db import CacheInva from kallithea.model.meta import Session from kallithea.model.ssh_key import SshKeyModel from kallithea.model.user import UserModel -from kallithea.tests.base import * +from kallithea.tests import base from kallithea.tests.fixture import Fixture @@ -65,12 +65,12 @@ class HttpVcsTest(object): class SshVcsTest(object): public_keys = { - TEST_USER_REGULAR_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', - TEST_USER_ADMIN_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', + base.TEST_USER_REGULAR_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost', + base.TEST_USER_ADMIN_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost', } @classmethod - def repo_url_param(cls, webserver, repo_name, username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS, client_ip=IP_ADDR): + def repo_url_param(cls, webserver, repo_name, username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS, client_ip=base.IP_ADDR): user = User.get_by_username(username) if user.ssh_keys: ssh_key = user.ssh_keys[0] @@ -84,11 +84,11 @@ class SshVcsTest(object): # Mixins for using Mercurial and Git class HgVcsTest(object): repo_type = 'hg' - repo_name = HG_REPO + repo_name = base.HG_REPO class GitVcsTest(object): repo_type = 'git' - repo_name = GIT_REPO + repo_name = base.GIT_REPO # Combine mixins to give the combinations we want to parameterize tests with class HgHttpVcsTest(HgVcsTest, HttpVcsTest): @@ -119,17 +119,17 @@ class GitSshVcsTest(GitVcsTest, SshVcsTe ssh_key.user_ssh_key_id) return "ssh://someuser@somehost/%s""" % repo_name -parametrize_vcs_test = parametrize('vt', [ +parametrize_vcs_test = base.parametrize('vt', [ HgHttpVcsTest, GitHttpVcsTest, HgSshVcsTest, GitSshVcsTest, ]) -parametrize_vcs_test_hg = parametrize('vt', [ +parametrize_vcs_test_hg = base.parametrize('vt', [ HgHttpVcsTest, HgSshVcsTest, ]) -parametrize_vcs_test_http = parametrize('vt', [ +parametrize_vcs_test_http = base.parametrize('vt', [ HgHttpVcsTest, GitHttpVcsTest, ]) @@ -167,7 +167,7 @@ class Command(object): def _get_tmp_dir(prefix='vcs_operations-', suffix=''): - return tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix=prefix, suffix=suffix) + return tempfile.mkdtemp(dir=base.TESTS_TMP_PATH, prefix=prefix, suffix=suffix) def _add_files(vcs, dest_dir, files_no=3): @@ -243,7 +243,7 @@ def _check_proper_git_push(stdout, stder @pytest.mark.usefixtures("test_context_fixture") -class TestVCSOperations(TestController): +class TestVCSOperations(base.TestController): @classmethod def setup_class(cls): @@ -263,16 +263,16 @@ class TestVCSOperations(TestController): @pytest.fixture(scope="module") def testfork(self): # create fork so the repo stays untouched - git_fork_name = u'%s_fork%s' % (GIT_REPO, _RandomNameSequence().next()) - fixture.create_fork(GIT_REPO, git_fork_name) - hg_fork_name = u'%s_fork%s' % (HG_REPO, _RandomNameSequence().next()) - fixture.create_fork(HG_REPO, hg_fork_name) + git_fork_name = u'%s_fork%s' % (base.GIT_REPO, _RandomNameSequence().next()) + fixture.create_fork(base.GIT_REPO, git_fork_name) + hg_fork_name = u'%s_fork%s' % (base.HG_REPO, _RandomNameSequence().next()) + fixture.create_fork(base.HG_REPO, hg_fork_name) return {'git': git_fork_name, 'hg': hg_fork_name} @parametrize_vcs_test def test_clone_repo_by_admin(self, webserver, vt): clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) if vt.repo_type == 'git': assert 'Cloning into' in stdout + stderr @@ -287,26 +287,26 @@ class TestVCSOperations(TestController): @parametrize_vcs_test_http def test_clone_wrong_credentials(self, webserver, vt): clone_url = vt.repo_url_param(webserver, vt.repo_name, password='bad!') - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) if vt.repo_type == 'git': assert 'fatal: Authentication failed' in stderr elif vt.repo_type == 'hg': assert 'abort: authorization failed' in stderr def test_clone_git_dir_as_hg(self, webserver): - clone_url = HgHttpVcsTest.repo_url_param(webserver, GIT_REPO) - stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) + clone_url = HgHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute('hg clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) assert 'HTTP Error 404: Not Found' in stderr or "not a valid repository" in stdout and 'abort:' in stderr def test_clone_hg_repo_as_git(self, webserver): - clone_url = GitHttpVcsTest.repo_url_param(webserver, HG_REPO) - stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) + clone_url = GitHttpVcsTest.repo_url_param(webserver, base.HG_REPO) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) assert 'not found' in stderr @parametrize_vcs_test def test_clone_non_existing_path(self, webserver, vt): clone_url = vt.repo_url_param(webserver, 'trololo') - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) if vt.repo_type == 'git': assert 'not found' in stderr or 'abort: Access to %r denied' % 'trololo' in stderr elif vt.repo_type == 'hg': @@ -320,13 +320,13 @@ class TestVCSOperations(TestController): # Create an empty server repo using the API repo_name = u'new_%s_%s' % (vt.repo_type, _RandomNameSequence().next()) - usr = User.get_by_username(TEST_USER_ADMIN_LOGIN) + usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN) params = { "id": 7, "api_key": usr.api_key, "method": 'create_repo', "args": dict(repo_name=repo_name, - owner=TEST_USER_ADMIN_LOGIN, + owner=base.TEST_USER_ADMIN_LOGIN, repo_type=vt.repo_type), } req = urllib2.Request( @@ -342,7 +342,7 @@ class TestVCSOperations(TestController): # Create local clone of the empty server repo local_clone_dir = _get_tmp_dir() clone_url = vt.repo_url_param(webserver, repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, local_clone_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, local_clone_dir) # Make 3 commits and push to the empty server repo. # The server repo doesn't have any other heads than the @@ -379,7 +379,7 @@ class TestVCSOperations(TestController): dest_dir = _get_tmp_dir() clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url=clone_url) @@ -401,7 +401,7 @@ class TestVCSOperations(TestController): Session().commit() dest_dir = _get_tmp_dir() - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'init', dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'init', dest_dir) clone_url = vt.repo_url_param(webserver, vt.repo_name) stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url) @@ -429,7 +429,7 @@ class TestVCSOperations(TestController): dest_dir = _get_tmp_dir() clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type]) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, files_no=1, clone_url=clone_url) @@ -447,7 +447,7 @@ class TestVCSOperations(TestController): def test_push_wrong_credentials(self, webserver, vt): dest_dir = _get_tmp_dir() clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) clone_url = webserver.repo_url(vt.repo_name, username='bad', password='name') stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, @@ -464,8 +464,8 @@ class TestVCSOperations(TestController): Session().commit() dest_dir = _get_tmp_dir() - clone_url = vt.repo_url_param(webserver, vt.repo_name, username=TEST_USER_REGULAR_LOGIN, password=TEST_USER_REGULAR_PASS) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + clone_url = vt.repo_url_param(webserver, vt.repo_name, username=base.TEST_USER_REGULAR_LOGIN, password=base.TEST_USER_REGULAR_PASS) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, ignoreReturnCode=True, clone_url=clone_url) @@ -482,7 +482,7 @@ class TestVCSOperations(TestController): def test_push_back_to_wrong_url(self, webserver, vt): dest_dir = _get_tmp_dir() clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) stdout, stderr = _add_files_and_push( webserver, vt, dest_dir, clone_url='http://%s:%s/tmp' % ( @@ -499,12 +499,12 @@ class TestVCSOperations(TestController): user_model = UserModel() try: # Add IP constraint that excludes the test context: - user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') + user_model.add_extra_ip(base.TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') Session().commit() # IP permissions are cached, need to wait for the cache in the server process to expire time.sleep(1.5) clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir(), ignoreReturnCode=True) if vt.repo_type == 'git': # The message apparently changed in Git 1.8.3, so match it loosely. assert re.search(r'\b403\b', stderr) or 'abort: User test_admin from 127.0.0.127 cannot be authorized' in stderr @@ -519,7 +519,7 @@ class TestVCSOperations(TestController): time.sleep(1.5) clone_url = vt.repo_url_param(webserver, vt.repo_name) - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, _get_tmp_dir()) if vt.repo_type == 'git': assert 'Cloning into' in stdout + stderr @@ -538,9 +538,9 @@ class TestVCSOperations(TestController): Ui.create_or_update_hook('preoutgoing.testhook', 'python:kallithea.tests.fixture.failing_test_hook') Session().commit() # clone repo - clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS) + clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) dest_dir = _get_tmp_dir() - stdout, stderr = Command(TESTS_TMP_PATH) \ + stdout, stderr = Command(base.TESTS_TMP_PATH) \ .execute(vt.repo_type, 'clone', clone_url, dest_dir, ignoreReturnCode=True) if vt.repo_type == 'hg': assert 'preoutgoing.testhook hook failed' in stdout @@ -553,9 +553,9 @@ class TestVCSOperations(TestController): Ui.create_or_update_hook('prechangegroup.testhook', 'python:kallithea.tests.fixture.failing_test_hook') Session().commit() # clone repo - clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS) + clone_url = vt.repo_url_param(webserver, testfork[vt.repo_type], username=base.TEST_USER_ADMIN_LOGIN, password=base.TEST_USER_ADMIN_PASS) dest_dir = _get_tmp_dir() - stdout, stderr = Command(TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute(vt.repo_type, 'clone', clone_url, dest_dir) stdout, stderr = _add_files_and_push(webserver, vt, dest_dir, clone_url, ignoreReturnCode=True) @@ -596,19 +596,19 @@ class TestVCSOperations(TestController): def test_add_submodule_git(self, webserver, testfork): dest_dir = _get_tmp_dir() - clone_url = GitHttpVcsTest.repo_url_param(webserver, GIT_REPO) + clone_url = GitHttpVcsTest.repo_url_param(webserver, base.GIT_REPO) fork_url = GitHttpVcsTest.repo_url_param(webserver, testfork['git']) # add submodule - stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir) + stdout, stderr = Command(base.TESTS_TMP_PATH).execute('git clone', fork_url, dest_dir) stdout, stderr = Command(dest_dir).execute('git submodule add', clone_url, 'testsubmodule') - stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"', EMAIL=TEST_USER_ADMIN_EMAIL) + stdout, stderr = Command(dest_dir).execute('git commit -am "added testsubmodule pointing to', clone_url, '"', EMAIL=base.TEST_USER_ADMIN_EMAIL) stdout, stderr = Command(dest_dir).execute('git push', fork_url, 'master') # check for testsubmodule link in files page self.log_user() - response = self.app.get(url(controller='files', action='index', + response = self.app.get(base.url(controller='files', action='index', repo_name=testfork['git'], revision='tip', f_path='/')) @@ -618,7 +618,7 @@ class TestVCSOperations(TestController): response.mustcontain('testsubmodule @ ' % clone_url) # check that following a submodule link actually works - and redirects - response = self.app.get(url(controller='files', action='index', + response = self.app.get(base.url(controller='files', action='index', repo_name=testfork['git'], revision='tip', f_path='/testsubmodule'), diff --git a/kallithea/tests/performance/test_vcs.py b/kallithea/tests/performance/test_vcs.py --- a/kallithea/tests/performance/test_vcs.py +++ b/kallithea/tests/performance/test_vcs.py @@ -15,11 +15,11 @@ import pytest from kallithea.model.db import Repository -from kallithea.tests.base import * +from kallithea.tests import base @pytest.mark.skipif("'TEST_PERFORMANCE' not in os.environ", reason="skipping performance tests, set TEST_PERFORMANCE in environment if desired") -class TestVCSPerformance(TestController): +class TestVCSPerformance(base.TestController): def graphmod(self, repo): """ Simple test for running the graph_data function for profiling/testing performance. """ @@ -31,7 +31,7 @@ class TestVCSPerformance(TestController) jsdata = graph_data(scm_inst, revs) def test_graphmod_hg(self, benchmark): - benchmark(self.graphmod, HG_REPO) + benchmark(self.graphmod, base.HG_REPO) def test_graphmod_git(self, benchmark): - benchmark(self.graphmod, GIT_REPO) + benchmark(self.graphmod, base.GIT_REPO)