Show More
@@ -1,94 +1,97 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.__init__ |
|
3 | rhodecode.__init__ | |
4 | ~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | RhodeCode, a web based repository management based on pylons |
|
6 | RhodeCode, a web based repository management based on pylons | |
7 | versioning implementation: http://www.python.org/dev/peps/pep-0386/ |
|
7 | versioning implementation: http://www.python.org/dev/peps/pep-0386/ | |
8 |
|
8 | |||
9 | :created_on: Apr 9, 2010 |
|
9 | :created_on: Apr 9, 2010 | |
10 | :author: marcink |
|
10 | :author: marcink | |
11 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
|
11 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> | |
12 | :license: GPLv3, see COPYING for more details. |
|
12 | :license: GPLv3, see COPYING for more details. | |
13 | """ |
|
13 | """ | |
14 | # This program is free software: you can redistribute it and/or modify |
|
14 | # This program is free software: you can redistribute it and/or modify | |
15 | # it under the terms of the GNU General Public License as published by |
|
15 | # it under the terms of the GNU General Public License as published by | |
16 | # the Free Software Foundation, either version 3 of the License, or |
|
16 | # the Free Software Foundation, either version 3 of the License, or | |
17 | # (at your option) any later version. |
|
17 | # (at your option) any later version. | |
18 | # |
|
18 | # | |
19 | # This program is distributed in the hope that it will be useful, |
|
19 | # This program is distributed in the hope that it will be useful, | |
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | # GNU General Public License for more details. |
|
22 | # GNU General Public License for more details. | |
23 | # |
|
23 | # | |
24 | # You should have received a copy of the GNU General Public License |
|
24 | # You should have received a copy of the GNU General Public License | |
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
26 | import sys |
|
26 | import sys | |
27 | import platform |
|
27 | import platform | |
28 |
|
28 | |||
29 | VERSION = (1, 3, 5, 'b') |
|
29 | VERSION = (1, 3, 5, 'b') | |
30 |
|
30 | |||
31 | try: |
|
31 | try: | |
32 | from rhodecode.lib import get_current_revision |
|
32 | from rhodecode.lib import get_current_revision | |
33 | _rev = get_current_revision() |
|
33 | _rev = get_current_revision() | |
34 | if _rev and len(VERSION) > 3: |
|
34 | if _rev and len(VERSION) > 3: | |
35 | VERSION += ('dev%s' % _rev[0],) |
|
35 | VERSION += ('dev%s' % _rev[0],) | |
36 | except ImportError: |
|
36 | except ImportError: | |
37 | pass |
|
37 | pass | |
38 |
|
38 | |||
39 | __version__ = ('.'.join((str(each) for each in VERSION[:3])) + |
|
39 | __version__ = ('.'.join((str(each) for each in VERSION[:3])) + | |
40 | '.'.join(VERSION[3:])) |
|
40 | '.'.join(VERSION[3:])) | |
41 | __dbversion__ = 5 # defines current db version for migrations |
|
41 | __dbversion__ = 5 # defines current db version for migrations | |
42 | __platform__ = platform.system() |
|
42 | __platform__ = platform.system() | |
43 | __license__ = 'GPLv3' |
|
43 | __license__ = 'GPLv3' | |
44 | __py_version__ = sys.version_info |
|
44 | __py_version__ = sys.version_info | |
45 |
|
45 | |||
46 | PLATFORM_WIN = ('Windows') |
|
46 | PLATFORM_WIN = ('Windows') | |
47 | PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS') |
|
47 | PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS') | |
48 |
|
48 | |||
|
49 | is_windows = __platform__ in PLATFORM_WIN | |||
|
50 | is_unix = __platform__ in PLATFORM_OTHERS | |||
|
51 | ||||
49 | requirements = [ |
|
52 | requirements = [ | |
50 | "Pylons==1.0.0", |
|
53 | "Pylons==1.0.0", | |
51 | "Beaker==1.6.3", |
|
54 | "Beaker==1.6.3", | |
52 | "WebHelpers==1.3", |
|
55 | "WebHelpers==1.3", | |
53 | "formencode==1.2.4", |
|
56 | "formencode==1.2.4", | |
54 | "SQLAlchemy==0.7.6", |
|
57 | "SQLAlchemy==0.7.6", | |
55 | "Mako==0.7.0", |
|
58 | "Mako==0.7.0", | |
56 | "pygments>=1.4", |
|
59 | "pygments>=1.4", | |
57 | "whoosh>=2.4.0,<2.5", |
|
60 | "whoosh>=2.4.0,<2.5", | |
58 | "celery>=2.2.5,<2.3", |
|
61 | "celery>=2.2.5,<2.3", | |
59 | "babel", |
|
62 | "babel", | |
60 | "python-dateutil>=1.5.0,<2.0.0", |
|
63 | "python-dateutil>=1.5.0,<2.0.0", | |
61 | "dulwich>=0.8.5,<0.9.0", |
|
64 | "dulwich>=0.8.5,<0.9.0", | |
62 | "webob==1.0.8", |
|
65 | "webob==1.0.8", | |
63 | "markdown==2.1.1", |
|
66 | "markdown==2.1.1", | |
64 | "docutils==0.8.1", |
|
67 | "docutils==0.8.1", | |
65 | ] |
|
68 | ] | |
66 |
|
69 | |||
67 | if __py_version__ < (2, 6): |
|
70 | if __py_version__ < (2, 6): | |
68 | requirements.append("simplejson") |
|
71 | requirements.append("simplejson") | |
69 | requirements.append("pysqlite") |
|
72 | requirements.append("pysqlite") | |
70 |
|
73 | |||
71 | if __platform__ in PLATFORM_WIN: |
|
74 | if is_windows: | |
72 | requirements.append("mercurial>=2.2.1,<2.3") |
|
75 | requirements.append("mercurial>=2.2.1,<2.3") | |
73 | else: |
|
76 | else: | |
74 | requirements.append("py-bcrypt") |
|
77 | requirements.append("py-bcrypt") | |
75 | requirements.append("mercurial>=2.2.1,<2.3") |
|
78 | requirements.append("mercurial>=2.2.1,<2.3") | |
76 |
|
79 | |||
77 |
|
80 | |||
78 | def get_version(): |
|
81 | def get_version(): | |
79 | """Returns shorter version (digit parts only) as string.""" |
|
82 | """Returns shorter version (digit parts only) as string.""" | |
80 |
|
83 | |||
81 | return '.'.join((str(each) for each in VERSION[:3])) |
|
84 | return '.'.join((str(each) for each in VERSION[:3])) | |
82 |
|
85 | |||
83 | BACKENDS = { |
|
86 | BACKENDS = { | |
84 | 'hg': 'Mercurial repository', |
|
87 | 'hg': 'Mercurial repository', | |
85 | 'git': 'Git repository', |
|
88 | 'git': 'Git repository', | |
86 | } |
|
89 | } | |
87 |
|
90 | |||
88 | CELERY_ON = False |
|
91 | CELERY_ON = False | |
89 |
|
92 | |||
90 | # link to config for pylons |
|
93 | # link to config for pylons | |
91 | CONFIG = {} |
|
94 | CONFIG = {} | |
92 |
|
95 | |||
93 | # Linked module for extensions |
|
96 | # Linked module for extensions | |
94 | EXTENSIONS = {} |
|
97 | EXTENSIONS = {} |
@@ -1,109 +1,112 b'' | |||||
1 | """Pylons application test package |
|
1 | """Pylons application test package | |
2 |
|
2 | |||
3 | This package assumes the Pylons environment is already loaded, such as |
|
3 | This package assumes the Pylons environment is already loaded, such as | |
4 | when this script is imported from the `nosetests --with-pylons=test.ini` |
|
4 | when this script is imported from the `nosetests --with-pylons=test.ini` | |
5 | command. |
|
5 | command. | |
6 |
|
6 | |||
7 | This module initializes the application via ``websetup`` (`paster |
|
7 | This module initializes the application via ``websetup`` (`paster | |
8 | setup-app`) and provides the base testing objects. |
|
8 | setup-app`) and provides the base testing objects. | |
9 | """ |
|
9 | """ | |
10 | import os |
|
10 | import os | |
11 | import time |
|
11 | import time | |
12 | import logging |
|
12 | import logging | |
13 | from os.path import join as jn |
|
13 | from os.path import join as jn | |
14 |
|
14 | |||
15 | from unittest import TestCase |
|
15 | from unittest import TestCase | |
16 | from tempfile import _RandomNameSequence |
|
16 | from tempfile import _RandomNameSequence | |
17 |
|
17 | |||
18 | from paste.deploy import loadapp |
|
18 | from paste.deploy import loadapp | |
19 | from paste.script.appinstall import SetupCommand |
|
19 | from paste.script.appinstall import SetupCommand | |
20 | from pylons import config, url |
|
20 | from pylons import config, url | |
21 | from routes.util import URLGenerator |
|
21 | from routes.util import URLGenerator | |
22 | from webtest import TestApp |
|
22 | from webtest import TestApp | |
23 |
|
23 | |||
|
24 | from rhodecode import is_windows | |||
24 | from rhodecode.model.meta import Session |
|
25 | from rhodecode.model.meta import Session | |
25 | from rhodecode.model.db import User |
|
26 | from rhodecode.model.db import User | |
26 |
|
27 | |||
27 | import pylons.test |
|
28 | import pylons.test | |
28 |
|
29 | |||
29 | os.environ['TZ'] = 'UTC' |
|
30 | os.environ['TZ'] = 'UTC' | |
30 | time.tzset() |
|
31 | if not is_windows: | |
|
32 | time.tzset() | |||
31 |
|
33 | |||
32 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
33 |
|
35 | |||
34 | __all__ = [ |
|
36 | __all__ = [ | |
35 | 'environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', |
|
37 | 'environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', | |
36 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', |
|
38 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', | |
37 | 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS', |
|
39 | 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS', | |
38 | 'TEST_USER_REGULAR_EMAIL', 'TEST_USER_REGULAR2_LOGIN', |
|
40 | 'TEST_USER_REGULAR_EMAIL', 'TEST_USER_REGULAR2_LOGIN', | |
39 | 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL' |
|
41 | 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL' | |
40 | ] |
|
42 | ] | |
41 |
|
43 | |||
42 | # Invoke websetup with the current config file |
|
44 | # Invoke websetup with the current config file | |
43 | # SetupCommand('setup-app').run([config_file]) |
|
45 | # SetupCommand('setup-app').run([config_file]) | |
44 |
|
46 | |||
45 | ##RUNNING DESIRED TESTS |
|
47 | ##RUNNING DESIRED TESTS | |
46 | # nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account |
|
48 | # nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account | |
47 | # nosetests --pdb --pdb-failures |
|
49 | # nosetests --pdb --pdb-failures | |
48 | environ = {} |
|
50 | environ = {} | |
49 |
|
51 | |||
50 | #SOME GLOBALS FOR TESTS |
|
52 | #SOME GLOBALS FOR TESTS | |
51 |
|
53 | |||
52 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) |
|
54 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) | |
53 | TEST_USER_ADMIN_LOGIN = 'test_admin' |
|
55 | TEST_USER_ADMIN_LOGIN = 'test_admin' | |
54 | TEST_USER_ADMIN_PASS = 'test12' |
|
56 | TEST_USER_ADMIN_PASS = 'test12' | |
55 | TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com' |
|
57 | TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com' | |
56 |
|
58 | |||
57 | TEST_USER_REGULAR_LOGIN = 'test_regular' |
|
59 | TEST_USER_REGULAR_LOGIN = 'test_regular' | |
58 | TEST_USER_REGULAR_PASS = 'test12' |
|
60 | TEST_USER_REGULAR_PASS = 'test12' | |
59 | TEST_USER_REGULAR_EMAIL = 'test_regular@mail.com' |
|
61 | TEST_USER_REGULAR_EMAIL = 'test_regular@mail.com' | |
60 |
|
62 | |||
61 | TEST_USER_REGULAR2_LOGIN = 'test_regular2' |
|
63 | TEST_USER_REGULAR2_LOGIN = 'test_regular2' | |
62 | TEST_USER_REGULAR2_PASS = 'test12' |
|
64 | TEST_USER_REGULAR2_PASS = 'test12' | |
63 | TEST_USER_REGULAR2_EMAIL = 'test_regular2@mail.com' |
|
65 | TEST_USER_REGULAR2_EMAIL = 'test_regular2@mail.com' | |
64 |
|
66 | |||
65 | HG_REPO = 'vcs_test_hg' |
|
67 | HG_REPO = 'vcs_test_hg' | |
66 | GIT_REPO = 'vcs_test_git' |
|
68 | GIT_REPO = 'vcs_test_git' | |
67 |
|
69 | |||
68 | NEW_HG_REPO = 'vcs_test_hg_new' |
|
70 | NEW_HG_REPO = 'vcs_test_hg_new' | |
69 | NEW_GIT_REPO = 'vcs_test_git_new' |
|
71 | NEW_GIT_REPO = 'vcs_test_git_new' | |
70 |
|
72 | |||
71 | HG_FORK = 'vcs_test_hg_fork' |
|
73 | HG_FORK = 'vcs_test_hg_fork' | |
72 | GIT_FORK = 'vcs_test_git_fork' |
|
74 | GIT_FORK = 'vcs_test_git_fork' | |
73 |
|
75 | |||
|
76 | ||||
74 | class TestController(TestCase): |
|
77 | class TestController(TestCase): | |
75 |
|
78 | |||
76 | def __init__(self, *args, **kwargs): |
|
79 | def __init__(self, *args, **kwargs): | |
77 | wsgiapp = pylons.test.pylonsapp |
|
80 | wsgiapp = pylons.test.pylonsapp | |
78 | config = wsgiapp.config |
|
81 | config = wsgiapp.config | |
79 |
|
82 | |||
80 | self.app = TestApp(wsgiapp) |
|
83 | self.app = TestApp(wsgiapp) | |
81 | url._push_object(URLGenerator(config['routes.map'], environ)) |
|
84 | url._push_object(URLGenerator(config['routes.map'], environ)) | |
82 | self.Session = Session |
|
85 | self.Session = Session | |
83 | self.index_location = config['app_conf']['index_dir'] |
|
86 | self.index_location = config['app_conf']['index_dir'] | |
84 | TestCase.__init__(self, *args, **kwargs) |
|
87 | TestCase.__init__(self, *args, **kwargs) | |
85 |
|
88 | |||
86 | def log_user(self, username=TEST_USER_ADMIN_LOGIN, |
|
89 | def log_user(self, username=TEST_USER_ADMIN_LOGIN, | |
87 | password=TEST_USER_ADMIN_PASS): |
|
90 | password=TEST_USER_ADMIN_PASS): | |
88 | self._logged_username = username |
|
91 | self._logged_username = username | |
89 | response = self.app.post(url(controller='login', action='index'), |
|
92 | response = self.app.post(url(controller='login', action='index'), | |
90 | {'username':username, |
|
93 | {'username':username, | |
91 | 'password':password}) |
|
94 | 'password':password}) | |
92 |
|
95 | |||
93 | if 'invalid user name' in response.body: |
|
96 | if 'invalid user name' in response.body: | |
94 | self.fail('could not login using %s %s' % (username, password)) |
|
97 | self.fail('could not login using %s %s' % (username, password)) | |
95 |
|
98 | |||
96 | self.assertEqual(response.status, '302 Found') |
|
99 | self.assertEqual(response.status, '302 Found') | |
97 | ses = response.session['rhodecode_user'] |
|
100 | ses = response.session['rhodecode_user'] | |
98 | self.assertEqual(ses.get('username'), username) |
|
101 | self.assertEqual(ses.get('username'), username) | |
99 | response = response.follow() |
|
102 | response = response.follow() | |
100 | self.assertEqual(ses.get('is_authenticated'), True) |
|
103 | self.assertEqual(ses.get('is_authenticated'), True) | |
101 |
|
104 | |||
102 | return response.session['rhodecode_user'] |
|
105 | return response.session['rhodecode_user'] | |
103 |
|
106 | |||
104 | def _get_logged_user(self): |
|
107 | def _get_logged_user(self): | |
105 | return User.get_by_username(self._logged_username) |
|
108 | return User.get_by_username(self._logged_username) | |
106 |
|
109 | |||
107 | def checkSessionFlash(self, response, msg): |
|
110 | def checkSessionFlash(self, response, msg): | |
108 | self.assertTrue('flash' in response.session) |
|
111 | self.assertTrue('flash' in response.session) | |
109 | self.assertTrue(msg in response.session['flash'][0][1]) |
|
112 | self.assertTrue(msg in response.session['flash'][0][1]) |
General Comments 0
You need to be logged in to leave comments.
Login now