##// END OF EJS Templates
created basic TestClass for tests that does...
marcink -
r3829:5067d6e8 beta
parent child Browse files
Show More
@@ -35,6 +35,7 b' import pylons'
35 35 import pylons.test
36 36 from pylons import config, url
37 37 from pylons.i18n.translation import _get_translator
38 from pylons.util import ContextObj
38 39
39 40 from routes.util import URLGenerator
40 41 from webtest import TestApp
@@ -55,7 +56,7 b' log = logging.getLogger(__name__)'
55 56
56 57 __all__ = [
57 58 'parameterized', 'environ', 'url', 'get_new_dir', 'TestController',
58 'SkipTest', 'ldap_lib_installed',
59 'SkipTest', 'ldap_lib_installed', 'BaseTestCase', 'init_stack',
59 60 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO',
60 61 'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
61 62 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
@@ -144,23 +145,31 b' def get_new_dir(title):'
144 145 return get_normalized_path(path)
145 146
146 147
147 class TestController(TestCase):
148
149 def __init__(self, *args, **kwargs):
150 wsgiapp = pylons.test.pylonsapp
151 config = wsgiapp.config
152
153 self.app = TestApp(wsgiapp)
148 def init_stack(config=None):
149 if not config:
150 config = pylons.test.pylonsapp.config
154 151 url._push_object(URLGenerator(config['routes.map'], environ))
155 152 pylons.app_globals._push_object(config['pylons.app_globals'])
156 153 pylons.config._push_object(config)
157
154 pylons.tmpl_context._push_object(ContextObj())
158 155 # Initialize a translator for tests that utilize i18n
159 156 translator = _get_translator(pylons.config.get('lang'))
160 157 pylons.translator._push_object(translator)
161 158
159
160 class BaseTestCase(TestCase):
161 def __init__(self, *args, **kwargs):
162 self.wsgiapp = pylons.test.pylonsapp
163 init_stack(self.wsgiapp.config)
164 TestCase.__init__(self, *args, **kwargs)
165
166
167 class TestController(BaseTestCase):
168
169 def __init__(self, *args, **kwargs):
170 BaseTestCase.__init__(self, *args, **kwargs)
171 self.app = TestApp(self.wsgiapp)
162 172 self.index_location = config['app_conf']['index_dir']
163 TestCase.__init__(self, *args, **kwargs)
164 173
165 174 def log_user(self, username=TEST_USER_ADMIN_LOGIN,
166 175 password=TEST_USER_ADMIN_PASS):
@@ -1,6 +1,3 b''
1 import os
2 import unittest
3 import functools
4 1 from rhodecode.tests import *
5 2 from rhodecode.tests.fixture import Fixture
6 3
@@ -1,6 +1,5 b''
1 1 from __future__ import with_statement
2 2 import os
3 import unittest
4 3 from rhodecode.tests import *
5 4 from rhodecode.lib.diffs import DiffProcessor, NEW_FILENODE, DEL_FILENODE, \
6 5 MOD_FILENODE, RENAMED_FILENODE, CHMOD_FILENODE, BIN_FILENODE
@@ -236,7 +235,7 b' DIFF_FIXTURES = {'
236 235 }
237 236
238 237
239 class DiffLibTest(unittest.TestCase):
238 class DiffLibTest(BaseTestCase):
240 239
241 240 @parameterized.expand([(x,) for x in DIFF_FIXTURES])
242 241 def test_diff(self, diff_fixture):
@@ -1,5 +1,3 b''
1 import os
2 import unittest
3 1 from rhodecode.tests import *
4 2
5 3 from rhodecode.model.db import User, Notification, UserNotification
@@ -9,7 +7,7 b' from rhodecode.model.meta import Session'
9 7 from rhodecode.model.notification import NotificationModel
10 8
11 9
12 class TestNotifications(unittest.TestCase):
10 class TestNotifications(BaseTestCase):
13 11
14 12 def __init__(self, methodName='runTest'):
15 13 Session.remove()
@@ -1,5 +1,3 b''
1 import os
2 import unittest
3 1 from rhodecode.tests import *
4 2 from rhodecode.tests.fixture import Fixture
5 3 from rhodecode.model.repos_group import ReposGroupModel
@@ -17,7 +15,7 b' from rhodecode.model.permission import P'
17 15 fixture = Fixture()
18 16
19 17
20 class TestPermissions(unittest.TestCase):
18 class TestPermissions(BaseTestCase):
21 19 def __init__(self, methodName='runTest'):
22 20 super(TestPermissions, self).__init__(methodName=methodName)
23 21
@@ -1,5 +1,3 b''
1 import os
2 import unittest
3 1 from rhodecode.tests import *
4 2
5 3 from rhodecode.model.meta import Session
@@ -11,7 +9,7 b' from rhodecode.lib.exceptions import Att'
11 9 fixture = Fixture()
12 10
13 11
14 class TestRepos(unittest.TestCase):
12 class TestRepos(BaseTestCase):
15 13
16 14 def setUp(self):
17 15 pass
@@ -1,5 +1,4 b''
1 1 import os
2 import unittest
3 2 from sqlalchemy.exc import IntegrityError
4 3
5 4 from rhodecode.tests import *
@@ -34,7 +33,7 b' def _update_repo(name, **kwargs):'
34 33 return r
35 34
36 35
37 class TestReposGroups(unittest.TestCase):
36 class TestReposGroups(BaseTestCase):
38 37
39 38 def setUp(self):
40 39 self.g1 = fixture.create_group('test1', skip_if_exists=True)
@@ -1,5 +1,3 b''
1 import os
2 import unittest
3 1 import functools
4 2 from rhodecode.tests import *
5 3
@@ -10,7 +8,6 b' from rhodecode.model.meta import Session'
10 8 from nose.tools import with_setup
11 9 from rhodecode.tests.models.common import _create_project_tree, check_tree_perms, \
12 10 _get_perms, _check_expected_count, expected_count, _destroy_project_tree
13 from rhodecode.model.repo import RepoModel
14 11
15 12
16 13 test_u1_id = None
@@ -1,4 +1,3 b''
1 import unittest
2 1 from rhodecode.tests import *
3 2
4 3 from rhodecode.model.db import User, UserGroup, UserGroupMember, UserEmailMap,\
@@ -12,7 +11,7 b' from rhodecode.tests.fixture import Fixt'
12 11 fixture = Fixture()
13 12
14 13
15 class TestUser(unittest.TestCase):
14 class TestUser(BaseTestCase):
16 15 def __init__(self, methodName='runTest'):
17 16 Session.remove()
18 17 super(TestUser, self).__init__(methodName=methodName)
@@ -87,7 +86,7 b' class TestUser(unittest.TestCase):'
87 86 Session().commit()
88 87
89 88
90 class TestUsers(unittest.TestCase):
89 class TestUsers(BaseTestCase):
91 90
92 91 def __init__(self, methodName='runTest'):
93 92 super(TestUsers, self).__init__(methodName=methodName)
@@ -1,5 +1,3 b''
1 import os
2 import unittest
3 1 import functools
4 2 from rhodecode.tests import *
5 3
@@ -23,7 +23,6 b''
23 23 # You should have received a copy of the GNU General Public License
24 24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 25 from __future__ import with_statement
26 import unittest
27 26 import datetime
28 27 import hashlib
29 28 import mock
@@ -64,7 +63,7 b' TEST_URLS += ['
64 63 ]
65 64
66 65
67 class TestLibs(unittest.TestCase):
66 class TestLibs(BaseTestCase):
68 67
69 68 @parameterized.expand(TEST_URLS)
70 69 def test_uri_filter(self, test_url, expected, expected_creds):
@@ -1,5 +1,4 b''
1 1 # -*- coding: utf-8 -*-
2 import unittest
3 2 import formencode
4 3
5 4 from rhodecode.tests import *
@@ -16,7 +15,7 b' from rhodecode.tests.fixture import Fixt'
16 15 fixture = Fixture()
17 16
18 17
19 class TestReposGroups(unittest.TestCase):
18 class TestReposGroups(BaseTestCase):
20 19
21 20 def setUp(self):
22 21 pass
@@ -151,7 +151,7 b' def set_anonymous_access(enable=True):'
151 151 # TESTS
152 152 #==============================================================================
153 153
154 class TestVCSOperations(unittest.TestCase):
154 class TestVCSOperations(BaseTestCase):
155 155
156 156 @classmethod
157 157 def setup_class(cls):
General Comments 0
You need to be logged in to leave comments. Login now