##// END OF EJS Templates
fixed tests import
marcink -
r1389:04edf762 beta
parent child Browse files
Show More
@@ -1,82 +1,81 b''
1 1 """Pylons application test package
2 2
3 3 This package assumes the Pylons environment is already loaded, such as
4 4 when this script is imported from the `nosetests --with-pylons=test.ini`
5 5 command.
6 6
7 7 This module initializes the application via ``websetup`` (`paster
8 8 setup-app`) and provides the base testing objects.
9 9 """
10 10 import os
11 11 from os.path import join as jn
12 12
13 13 from unittest import TestCase
14 14
15 15 from paste.deploy import loadapp
16 16 from paste.script.appinstall import SetupCommand
17 17 from pylons import config, url
18 18 from routes.util import URLGenerator
19 19 from webtest import TestApp
20 20
21 21 from rhodecode.model import meta
22 22 import logging
23 23
24 24
25 25 log = logging.getLogger(__name__)
26 26
27 27 import pylons.test
28 28
29 29 __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO',
30 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK',
31 'checkSessionFlash' ]
30 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', ]
32 31
33 32 # Invoke websetup with the current config file
34 33 #SetupCommand('setup-app').run([config_file])
35 34
36 35 ##RUNNING DESIRED TESTS
37 36 #nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account
38 37
39 38 environ = {}
40 39
41 40 #SOME GLOBALS FOR TESTS
42 41 TESTS_TMP_PATH = jn('/', 'tmp')
43 42
44 43 HG_REPO = 'vcs_test_hg'
45 44 GIT_REPO = 'vcs_test_git'
46 45
47 46 NEW_HG_REPO = 'vcs_test_hg_new'
48 47 NEW_GIT_REPO = 'vcs_test_git_new'
49 48
50 49 HG_FORK = 'vcs_test_hg_fork'
51 50 GIT_FORK = 'vcs_test_git_fork'
52 51
53 52 class TestController(TestCase):
54 53
55 54 def __init__(self, *args, **kwargs):
56 55 wsgiapp = pylons.test.pylonsapp
57 56 config = wsgiapp.config
58 57
59 58 self.app = TestApp(wsgiapp)
60 59 url._push_object(URLGenerator(config['routes.map'], environ))
61 60 self.sa = meta.Session
62 61 self.index_location = config['app_conf']['index_dir']
63 62 TestCase.__init__(self, *args, **kwargs)
64 63
65 64 def log_user(self, username='test_admin', password='test12'):
66 65 response = self.app.post(url(controller='login', action='index'),
67 66 {'username':username,
68 67 'password':password})
69 68
70 69 if 'invalid user name' in response.body:
71 70 self.fail('could not login using %s %s' % (username, password))
72 71
73 72 self.assertEqual(response.status, '302 Found')
74 73 self.assertEqual(response.session['rhodecode_user'].username, username)
75 74 return response.follow()
76 75
77 76
78 77
79 78 def checkSessionFlash(self, response, msg):
80 79 self.assertTrue('flash' in response.session)
81 80 self.assertTrue(msg in response.session['flash'][0][1])
82 81
General Comments 0
You need to be logged in to leave comments. Login now