Mercurial > kallithea
annotate kallithea/tests/__init__.py @ 4732:0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 06 Jan 2015 00:54:36 +0100 |
parents | 5225ed43bbb3 |
children | 787f30a1a996 |
rev | line source |
---|---|
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
1 # -*- coding: utf-8 -*- |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
5 # (at your option) any later version. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
6 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
10 # GNU General Public License for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
11 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
14 |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
15 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
16 Pylons application test package |
0 | 17 |
18 This package assumes the Pylons environment is already loaded, such as | |
19 when this script is imported from the `nosetests --with-pylons=test.ini` | |
20 command. | |
21 | |
22 This module initializes the application via ``websetup`` (`paster | |
23 setup-app`) and provides the base testing objects. | |
3637 | 24 |
25 nosetests -x - fail on first error | |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
26 nosetests kallithea.tests.functional.test_admin_settings:TestSettingsController.test_my_account |
3637 | 27 nosetests --pdb --pdb-failures |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
28 nosetests --with-coverage --cover-package=kallithea.model.validators kallithea.tests.test_validators |
3637 | 29 |
30 optional FLAGS: | |
4206
703d3208424c
Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4197
diff
changeset
|
31 KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests |
703d3208424c
Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4197
diff
changeset
|
32 KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for test_vcs_operations |
3637 | 33 |
0 | 34 """ |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
35 import os |
1707
54fda6ce9e98
fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
36 import time |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
37 import logging |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
38 import datetime |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
39 import hashlib |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
40 import tempfile |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
41 from os.path import join as jn |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
42 |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
43 from tempfile import _RandomNameSequence |
0 | 44 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3674
diff
changeset
|
45 import pylons |
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3674
diff
changeset
|
46 import pylons.test |
0 | 47 from pylons import config, url |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3674
diff
changeset
|
48 from pylons.i18n.translation import _get_translator |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
49 from pylons.util import ContextObj |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3674
diff
changeset
|
50 |
0 | 51 from routes.util import URLGenerator |
52 from webtest import TestApp | |
3646
63e49418a4cc
Use only mustcontain for testing response body
Marcin Kuzminski <marcin@python-works.com>
parents:
3637
diff
changeset
|
53 from nose.plugins.skip import SkipTest |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
54 |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
55 from kallithea.lib.compat import unittest |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
56 from kallithea import is_windows |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
57 from kallithea.model.db import User |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
58 from kallithea.tests.nose_parametrized import parameterized |
4422
d51a6f5e57d1
cleanup: remove unused Python imports, found with pyflakes
Mads Kiilerich <madski@unity3d.com>
parents:
4206
diff
changeset
|
59 from kallithea.lib.utils2 import safe_str |
1707
54fda6ce9e98
fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
60 |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
61 |
1707
54fda6ce9e98
fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
62 os.environ['TZ'] = 'UTC' |
2254
8b1a79ad7a42
fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
63 if not is_windows: |
8b1a79ad7a42
fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
64 time.tzset() |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
65 |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
66 log = logging.getLogger(__name__) |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
469
diff
changeset
|
67 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
68 __all__ = [ |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
69 'parameterized', 'environ', 'url', 'get_new_dir', 'TestController', |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
70 'SkipTest', 'ldap_lib_installed', 'BaseTestCase', 'init_stack', |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
71 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
72 'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS', |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
73 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS', |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
74 'TEST_USER_REGULAR_EMAIL', 'TEST_USER_REGULAR2_LOGIN', |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
75 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
76 'TEST_HG_REPO_CLONE', 'TEST_HG_REPO_PULL', 'TEST_GIT_REPO', |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2629
diff
changeset
|
77 'TEST_GIT_REPO_CLONE', 'TEST_GIT_REPO_PULL', 'HG_REMOTE_REPO', |
3647
8a86836fad64
more usage of fixture tools
Marcin Kuzminski <marcin@python-works.com>
parents:
3646
diff
changeset
|
78 'GIT_REMOTE_REPO', 'SCM_TESTS', |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
79 ] |
0 | 80 |
81 # Invoke websetup with the current config file | |
1628
de71a4bde097
Some code cleanups and fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1594
diff
changeset
|
82 # SetupCommand('setup-app').run([config_file]) |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
83 |
0 | 84 environ = {} |
85 | |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
86 #SOME GLOBALS FOR TESTS |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
87 |
1397
dc960653f8d2
Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents:
1389
diff
changeset
|
88 TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) |
1416
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
89 TEST_USER_ADMIN_LOGIN = 'test_admin' |
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
90 TEST_USER_ADMIN_PASS = 'test12' |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
91 TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
92 |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
93 TEST_USER_REGULAR_LOGIN = 'test_regular' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
94 TEST_USER_REGULAR_PASS = 'test12' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
95 TEST_USER_REGULAR_EMAIL = 'test_regular@mail.com' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
96 |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
97 TEST_USER_REGULAR2_LOGIN = 'test_regular2' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
98 TEST_USER_REGULAR2_PASS = 'test12' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
99 TEST_USER_REGULAR2_EMAIL = 'test_regular2@mail.com' |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1723
diff
changeset
|
100 |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
101 HG_REPO = 'vcs_test_hg' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
102 GIT_REPO = 'vcs_test_git' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
103 |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
104 NEW_HG_REPO = 'vcs_test_hg_new' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
105 NEW_GIT_REPO = 'vcs_test_git_new' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
106 |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
107 HG_FORK = 'vcs_test_hg_fork' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
108 GIT_FORK = 'vcs_test_git_fork' |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
109 |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
110 ## VCS |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
111 SCM_TESTS = ['hg', 'git'] |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
112 uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple()))) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
113 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
114 GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git' |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
115 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
116 TEST_GIT_REPO = jn(TESTS_TMP_PATH, GIT_REPO) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
117 TEST_GIT_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcsgitclone%s' % uniq_suffix) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
118 TEST_GIT_REPO_PULL = jn(TESTS_TMP_PATH, 'vcsgitpull%s' % uniq_suffix) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
119 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
120 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
121 HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs' |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
122 |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
123 TEST_HG_REPO = jn(TESTS_TMP_PATH, HG_REPO) |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
124 TEST_HG_REPO_CLONE = jn(TESTS_TMP_PATH, 'vcshgclone%s' % uniq_suffix) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
125 TEST_HG_REPO_PULL = jn(TESTS_TMP_PATH, 'vcshgpull%s' % uniq_suffix) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
126 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
127 TEST_DIR = tempfile.gettempdir() |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
128 TEST_REPO_PREFIX = 'vcs-test' |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
129 |
2459
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
130 # cached repos if any ! |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
131 # comment out to get some other repos from bb or github |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
132 GIT_REMOTE_REPO = jn(TESTS_TMP_PATH, GIT_REPO) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
133 HG_REMOTE_REPO = jn(TESTS_TMP_PATH, HG_REPO) |
9492ab68331f
Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents:
2451
diff
changeset
|
134 |
3674
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
135 #skip ldap tests if LDAP lib is not installed |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
136 ldap_lib_installed = False |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
137 try: |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
138 import ldap |
4422
d51a6f5e57d1
cleanup: remove unused Python imports, found with pyflakes
Mads Kiilerich <madski@unity3d.com>
parents:
4206
diff
changeset
|
139 ldap.API_VERSION |
3674
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
140 ldap_lib_installed = True |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
141 except ImportError: |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
142 # means that python-ldap is not installed |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
143 pass |
ff2ea58debb5
fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents:
3647
diff
changeset
|
144 |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
145 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
146 def get_new_dir(title): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
147 """ |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
148 Returns always new directory path. |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
149 """ |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4116
diff
changeset
|
150 from kallithea.tests.vcs.utils import get_normalized_path |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
151 name = TEST_REPO_PREFIX |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
152 if title: |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
153 name = '-'.join((name, title)) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
154 hex = hashlib.sha1(str(time.time())).hexdigest() |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
155 name = '-'.join((name, hex)) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
156 path = os.path.join(TEST_DIR, name) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
157 return get_normalized_path(path) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
158 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
159 |
4732
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
160 import logging |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
161 |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
162 class NullHandler(logging.Handler): |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
163 def emit(self, record): |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
164 pass |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
165 |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
166 def init_stack(config=None): |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
167 if not config: |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
168 config = pylons.test.pylonsapp.config |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
169 url._push_object(URLGenerator(config['routes.map'], environ)) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
170 pylons.app_globals._push_object(config['pylons.app_globals']) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
171 pylons.config._push_object(config) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
172 pylons.tmpl_context._push_object(ContextObj()) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
173 # Initialize a translator for tests that utilize i18n |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
174 translator = _get_translator(pylons.config.get('lang')) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
175 pylons.translator._push_object(translator) |
4732
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
176 h = NullHandler() |
0f96804480c3
tests: create default logging handler to mute 'No handlers could be found for logger' warnings
Mads Kiilerich <madski@unity3d.com>
parents:
4697
diff
changeset
|
177 logging.getLogger("kallithea").addHandler(h) |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
178 |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
179 |
3872
2b9da8749065
Use unittest2 for testing
Marcin Kuzminski <marcin@python-works.com>
parents:
3829
diff
changeset
|
180 class BaseTestCase(unittest.TestCase): |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
181 def __init__(self, *args, **kwargs): |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
182 self.wsgiapp = pylons.test.pylonsapp |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
183 init_stack(self.wsgiapp.config) |
3872
2b9da8749065
Use unittest2 for testing
Marcin Kuzminski <marcin@python-works.com>
parents:
3829
diff
changeset
|
184 unittest.TestCase.__init__(self, *args, **kwargs) |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
185 |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
186 |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
187 class TestController(BaseTestCase): |
0 | 188 |
189 def __init__(self, *args, **kwargs): | |
3829
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
190 BaseTestCase.__init__(self, *args, **kwargs) |
5067d6e826a5
created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents:
3797
diff
changeset
|
191 self.app = TestApp(self.wsgiapp) |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
192 self.maxDiff = None |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
193 self.index_location = config['app_conf']['index_dir'] |
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
194 |
1416
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
195 def log_user(self, username=TEST_USER_ADMIN_LOGIN, |
df04752daa64
test env update
Marcin Kuzminski <marcin@python-works.com>
parents:
1397
diff
changeset
|
196 password=TEST_USER_ADMIN_PASS): |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
197 self._logged_username = username |
464
cbe777be5b8c
some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
198 response = self.app.post(url(controller='login', action='index'), |
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
199 {'username': username, |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
2254
diff
changeset
|
200 'password': password}) |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
201 |
534
12c976209b2e
fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
202 if 'invalid user name' in response.body: |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
203 self.fail('could not login using %s %s' % (username, password)) |
688
8acbfa837180
Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
204 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
205 self.assertEqual(response.status, '302 Found') |
4197
d208416c84c6
Rename rhodecode_user to authuser - it is an AuthUser instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
206 ses = response.session['authuser'] |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
207 self.assertEqual(ses.get('username'), username) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
208 response = response.follow() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
209 self.assertEqual(ses.get('is_authenticated'), True) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
210 |
4197
d208416c84c6
Rename rhodecode_user to authuser - it is an AuthUser instance
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
211 return response.session['authuser'] |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
212 |
1712
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
213 def _get_logged_user(self): |
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
214 return User.get_by_username(self._logged_username) |
cac5109ac3b6
Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents:
1707
diff
changeset
|
215 |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
216 def checkSessionFlash(self, response, msg): |
3219
42d7ca49d073
added test for setting repo as private which should set perm => None for default user
Marcin Kuzminski <marcin@python-works.com>
parents:
3057
diff
changeset
|
217 self.assertTrue('flash' in response.session, |
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3960
diff
changeset
|
218 msg='Response session have no flash key' % response.session) |
4697
5225ed43bbb3
tests: let checkSessionFlash search through all messages
Mads Kiilerich <madski@unity3d.com>
parents:
4422
diff
changeset
|
219 if not any(msg in m for level, m in response.session['flash']): |
5225ed43bbb3
tests: let checkSessionFlash search through all messages
Mads Kiilerich <madski@unity3d.com>
parents:
4422
diff
changeset
|
220 for level, m in response.session['flash']: |
5225ed43bbb3
tests: let checkSessionFlash search through all messages
Mads Kiilerich <madski@unity3d.com>
parents:
4422
diff
changeset
|
221 msg = u'msg `%s` not found in session flash: got `%s` instead' % (msg, m) |
5225ed43bbb3
tests: let checkSessionFlash search through all messages
Mads Kiilerich <madski@unity3d.com>
parents:
4422
diff
changeset
|
222 self.fail(safe_str(msg)) |
5225ed43bbb3
tests: let checkSessionFlash search through all messages
Mads Kiilerich <madski@unity3d.com>
parents:
4422
diff
changeset
|
223 msg = u'msg `%s` not found in empty session flash' % (msg) |
3550
7abbb77b02d0
Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents:
3459
diff
changeset
|
224 self.fail(safe_str(msg)) |