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