annotate rhodecode/tests/__init__.py @ 2451:402a96fcfa22 beta

Added vcs testsuite for better integration tests + added fetching of two new repos into test env for rhodecode
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 13 Jun 2012 23:27:33 +0200
parents 8b1a79ad7a42
children 9492ab68331f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """Pylons application test package
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 This package assumes the Pylons environment is already loaded, such as
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
4 when this script is imported from the `nosetests --with-pylons=test.ini`
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
5 command.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
6
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
7 This module initializes the application via ``websetup`` (`paster
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
8 setup-app`) and provides the base testing objects.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
9 """
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
10 import os
1707
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
11 import time
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
12 import logging
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
13 import datetime
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
14 import hashlib
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
15 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
16 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
17
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
18 from unittest import TestCase
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
19 from tempfile import _RandomNameSequence
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
20
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
21 from paste.deploy import loadapp
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
22 from paste.script.appinstall import SetupCommand
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 from pylons import config, url
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 from routes.util import URLGenerator
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
25 from webtest import TestApp
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
26
2254
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
27 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
28 from rhodecode.model.meta import Session
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
29 from rhodecode.model.db import User
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
30
1707
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
31 import pylons.test
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
32
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
33
1707
54fda6ce9e98 fixes timezone issues with tests
Marcin Kuzminski <marcin@python-works.com>
parents: 1628
diff changeset
34 os.environ['TZ'] = 'UTC'
2254
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
35 if not is_windows:
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
36 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
37
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
38 log = logging.getLogger(__name__)
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
39
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
40 __all__ = [
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
41 'environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO',
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
42 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK',
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
43 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_REGULAR_LOGIN',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
44 'TEST_USER_REGULAR_PASS', 'TEST_USER_REGULAR_EMAIL',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
45 'TEST_USER_REGULAR2_LOGIN', 'TEST_USER_REGULAR2_PASS',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
46 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', 'TEST_GIT_REPO',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
47 'HG_REMOTE_REPO', '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
48 ]
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
49
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
50 # Invoke websetup with the current config file
1628
de71a4bde097 Some code cleanups and fixes
Marcin Kuzminski <marcin@python-works.com>
parents: 1594
diff changeset
51 # 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
52
535
72778dda34cf some fixups in cache, added fallback and cache invalidation when key not found in cached repos list,
Marcin Kuzminski <marcin@python-works.com>
parents: 534
diff changeset
53 ##RUNNING DESIRED TESTS
1416
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
54 # nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1758
diff changeset
55 # nosetests --pdb --pdb-failures
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
56 environ = {}
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
57
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
58 #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
59
1397
dc960653f8d2 Added new random directory for each test to be better sandboxed
Marcin Kuzminski <marcin@python-works.com>
parents: 1389
diff changeset
60 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
61 TEST_USER_ADMIN_LOGIN = 'test_admin'
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
62 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
63 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
64
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
65 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
66 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
67 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
68
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1723
diff changeset
69 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
70 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
71 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
72
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
73 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
74 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
75
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
76 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
77 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
78
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
79 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
80 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
81
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
82 ## VCS
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
83 SCM_TESTS = ['hg', 'git']
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
84 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
85
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
86 THIS = os.path.abspath(os.path.dirname(__file__))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
87
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
88 GIT_REMOTE_REPO = 'git://github.com/codeinn/vcs.git'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
89 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
90 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
91 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
92
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
93
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
94 HG_REMOTE_REPO = 'http://bitbucket.org/marcinkuzminski/vcs'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
95 TEST_HG_REPO = jn(TESTS_TMP_PATH, 'vcs-hg')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
96 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
97 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
98
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
99 TEST_DIR = tempfile.gettempdir()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
100 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
101
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
102
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
103 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
104 """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
105 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
106 """
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
107 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
108 name = TEST_REPO_PREFIX
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
109 if title:
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
110 name = '-'.join((name, title))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
111 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
112 name = '-'.join((name, hex))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
113 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
114 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
115
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
116
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
117 PACKAGE_DIR = os.path.abspath(os.path.join(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
118 os.path.dirname(__file__), '..'))
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_USER_CONFIG_FILE = jn(THIS, 'aconfig')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
121
2254
8b1a79ad7a42 fix windows test issue with tzset()
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
122
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
123 class TestController(TestCase):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
124
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
125 def __init__(self, *args, **kwargs):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
126 wsgiapp = pylons.test.pylonsapp
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
127 config = wsgiapp.config
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
128
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
129 self.app = TestApp(wsgiapp)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
130 url._push_object(URLGenerator(config['routes.map'], environ))
1723
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
131 self.Session = Session
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
132 self.index_location = config['app_conf']['index_dir']
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
133 TestCase.__init__(self, *args, **kwargs)
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
134
1416
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
135 def log_user(self, username=TEST_USER_ADMIN_LOGIN,
df04752daa64 test env update
Marcin Kuzminski <marcin@python-works.com>
parents: 1397
diff changeset
136 password=TEST_USER_ADMIN_PASS):
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
137 self._logged_username = username
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
138 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
139 {'username': username,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 2254
diff changeset
140 'password': password})
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
141
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
142 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
143 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
144
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
145 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
146 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
147 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
148 response = response.follow()
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
149 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
150
64e91067b996 - refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents: 1718
diff changeset
151 return response.session['rhodecode_user']
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
152
1712
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
153 def _get_logged_user(self):
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
154 return User.get_by_username(self._logged_username)
cac5109ac3b6 Notification system improvements
Marcin Kuzminski <marcin@python-works.com>
parents: 1707
diff changeset
155
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
156 def checkSessionFlash(self, response, msg):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
157 self.assertTrue('flash' in response.session)
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
158 self.assertTrue(msg in response.session['flash'][0][1])