annotate rhodecode/tests/__init__.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl

Imported some of the GPLv3'd changes from RhodeCode v2.2.5. This imports changes between changesets 21af6c4eab3d and 6177597791c2 in RhodeCode's original repository, including only changes to Python files and HTML. RhodeCode clearly licensed its changes to these files under GPLv3 in their /LICENSE file, which states the following: The Python code and integrated HTML are licensed under the GPLv3 license. (See: https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE or http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE for an online copy of that LICENSE file) Conservancy reviewed these changes and confirmed that they can be licensed as a whole to the Kallithea project under GPLv3-only. While some of the contents committed herein are clearly licensed GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the statement above from RhodeCode indicates that they intend GPLv3-only as their license, per GPLv3ยง14 and other relevant sections of GPLv3.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:03:13 -0400
parents 5293d4bbb1ea
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
17
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
18 This package assumes the Pylons environment is already loaded, such as
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
19 when this script is imported from the `nosetests --with-pylons=test.ini`
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
20 command.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
21
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
22 This module initializes the application via ``websetup`` (`paster
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 setup-app`) and provides the base testing objects.
3637
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
24
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
25 nosetests -x - fail on first error
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
26 nosetests rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
27 nosetests --pdb --pdb-failures
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
28 nosetests --with-coverage --cover-package=rhodecode.model.validators rhodecode.tests.test_validators
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
29
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
30 optional FLAGS:
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
31 RC_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
32 RC_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for test_vcs_operations
58c2b54540d2 tests docs
Marcin Kuzminski <marcin@python-works.com>
parents: 3550
diff changeset
33
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
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
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
44
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
45 from paste.deploy import loadapp
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
46 from paste.script.appinstall import SetupCommand
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3674
diff changeset
47
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3674
diff changeset
48 import pylons
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3674
diff changeset
49 import pylons.test
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
50 from pylons import config, url
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3674
diff changeset
51 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
52 from pylons.util import ContextObj
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3674
diff changeset
53
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
54 from routes.util import URLGenerator
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
55 from webtest import TestApp
3646
63e49418a4cc Use only mustcontain for testing response body
Marcin Kuzminski <marcin@python-works.com>
parents: 3637
diff changeset
56 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
57
3872
2b9da8749065 Use unittest2 for testing
Marcin Kuzminski <marcin@python-works.com>
parents: 3829
diff changeset
58 from rhodecode.lib.compat import unittest
2254
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
59 from rhodecode import is_windows
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
60 from rhodecode.model.meta import Session
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
61 from rhodecode.model.db import User
2466
7010dc12f10c Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
62 from rhodecode.tests.nose_parametrized import parameterized
3550
7abbb77b02d0 Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
63 from rhodecode.lib.utils2 import safe_unicode, safe_str
1707
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
64
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
65
1707
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
66 os.environ['TZ'] = 'UTC'
2254
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
67 if not is_windows:
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
68 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
69
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
70 log = logging.getLogger(__name__)
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
71
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
72 __all__ = [
2466
7010dc12f10c Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
73 '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
74 'SkipTest', 'ldap_lib_installed', 'BaseTestCase', 'init_stack',
2466
7010dc12f10c Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
75 '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
76 '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
77 '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
78 '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
79 '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
80 '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
81 '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
82 '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
83 ]
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
84
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
85 # Invoke websetup with the current config file
1628
de71a4bde097 Some code cleanups and fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1594
diff changeset
86 # 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
87
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
88 environ = {}
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
89
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
90 #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
91
1397
dc960653f8d2 Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents: 1389
diff changeset
92 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
93 TEST_USER_ADMIN_LOGIN = 'test_admin'
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
94 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
95 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
96
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
97 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
98 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
99 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
100
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
101 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
102 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
103 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
104
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
105 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
106 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
107
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 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
109 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
110
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
111 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
112 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
113
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
114 ## VCS
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
115 SCM_TESTS = ['hg', 'git']
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
116 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
117
2459
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
118 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
119
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
120 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
121 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
122 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
123
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
124
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
125 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
126
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
127 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
128 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
129 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
130
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
131 TEST_DIR = tempfile.gettempdir()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
132 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
133
2459
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
134 # cached repos if any !
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
135 # 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
136 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
137 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
138
3674
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
139 #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
140 ldap_lib_installed = False
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
141 try:
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
142 import ldap
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
143 ldap_lib_installed = True
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
144 except ImportError:
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
145 # 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
146 pass
ff2ea58debb5 fixed ldap tests when ldap lib is installed
Marcin Kuzminski <marcin@python-works.com>
parents: 3647
diff changeset
147
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
148
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
149 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
150 """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
151 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
152 """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
153 from rhodecode.tests.vcs.utils import get_normalized_path
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
154 name = TEST_REPO_PREFIX
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
155 if title:
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
156 name = '-'.join((name, title))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
157 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
158 name = '-'.join((name, hex))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
159 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
160 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
161
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
162
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
163 def init_stack(config=None):
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
164 if not config:
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
165 config = pylons.test.pylonsapp.config
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
166 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
167 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
168 pylons.config._push_object(config)
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
169 pylons.tmpl_context._push_object(ContextObj())
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
170 # 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
171 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
172 pylons.translator._push_object(translator)
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
173
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
174
3872
2b9da8749065 Use unittest2 for testing
Marcin Kuzminski <marcin@python-works.com>
parents: 3829
diff changeset
175 class BaseTestCase(unittest.TestCase):
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
176 def __init__(self, *args, **kwargs):
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
177 self.wsgiapp = pylons.test.pylonsapp
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
178 init_stack(self.wsgiapp.config)
3872
2b9da8749065 Use unittest2 for testing
Marcin Kuzminski <marcin@python-works.com>
parents: 3829
diff changeset
179 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
180
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
181
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
182 class TestController(BaseTestCase):
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
183
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
184 def __init__(self, *args, **kwargs):
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
185 BaseTestCase.__init__(self, *args, **kwargs)
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3797
diff changeset
186 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
187 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
188 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
189
1416
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
190 def log_user(self, username=TEST_USER_ADMIN_LOGIN,
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
191 password=TEST_USER_ADMIN_PASS):
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
192 self._logged_username = username
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
193 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
194 {'username': username,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
195 'password': password})
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
196
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
197 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
198 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
199
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
200 self.assertEqual(response.status, '302 Found')
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
201 ses = response.session['rhodecode_user']
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
202 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
203 response = response.follow()
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
204 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
205
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
206 return response.session['rhodecode_user']
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
207
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
208 def _get_logged_user(self):
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
209 return User.get_by_username(self._logged_username)
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
210
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
211 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
212 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
213 msg='Response session have no flash key' % response.session)
2530
f17e001cc6cc better error message in checkSession in tests
Marcin Kuzminski <marcin@python-works.com>
parents: 2478
diff changeset
214 if not msg in response.session['flash'][0][1]:
3550
7abbb77b02d0 Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
215 msg = u'msg `%s` not found in session flash: got `%s` instead' % (
7abbb77b02d0 Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
216 msg, response.session['flash'][0][1])
7abbb77b02d0 Repo size - show just the size without duplicating text
Marcin Kuzminski <marcin@python-works.com>
parents: 3459
diff changeset
217 self.fail(safe_str(msg))