Show More
@@ -1,82 +1,85 b'' | |||||
1 | """Pylons application test package |
|
1 | """Pylons application test package | |
2 |
|
2 | |||
3 | This package assumes the Pylons environment is already loaded, such as |
|
3 | This package assumes the Pylons environment is already loaded, such as | |
4 | when this script is imported from the `nosetests --with-pylons=test.ini` |
|
4 | when this script is imported from the `nosetests --with-pylons=test.ini` | |
5 | command. |
|
5 | command. | |
6 |
|
6 | |||
7 | This module initializes the application via ``websetup`` (`paster |
|
7 | This module initializes the application via ``websetup`` (`paster | |
8 | setup-app`) and provides the base testing objects. |
|
8 | setup-app`) and provides the base testing objects. | |
9 | """ |
|
9 | """ | |
10 | import os |
|
10 | import os | |
|
11 | import time | |||
11 | from os.path import join as jn |
|
12 | from os.path import join as jn | |
12 |
|
13 | |||
13 | from unittest import TestCase |
|
14 | from unittest import TestCase | |
14 |
|
15 | |||
15 | from paste.deploy import loadapp |
|
16 | from paste.deploy import loadapp | |
16 | from paste.script.appinstall import SetupCommand |
|
17 | from paste.script.appinstall import SetupCommand | |
17 | from pylons import config, url |
|
18 | from pylons import config, url | |
18 | from routes.util import URLGenerator |
|
19 | from routes.util import URLGenerator | |
19 | from webtest import TestApp |
|
20 | from webtest import TestApp | |
20 |
|
21 | |||
21 | from rhodecode.model import meta |
|
22 | from rhodecode.model import meta | |
22 | import logging |
|
23 | import logging | |
|
24 | import pylons.test | |||
|
25 | ||||
|
26 | os.environ['TZ'] = 'UTC' | |||
|
27 | time.tzset() | |||
23 |
|
28 | |||
24 | log = logging.getLogger(__name__) |
|
29 | log = logging.getLogger(__name__) | |
25 |
|
30 | |||
26 | import pylons.test |
|
|||
27 |
|
||||
28 | __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', |
|
31 | __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', | |
29 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', |
|
32 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', | |
30 | 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS' ] |
|
33 | 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS' ] | |
31 |
|
34 | |||
32 | # Invoke websetup with the current config file |
|
35 | # Invoke websetup with the current config file | |
33 | # SetupCommand('setup-app').run([config_file]) |
|
36 | # SetupCommand('setup-app').run([config_file]) | |
34 |
|
37 | |||
35 | ##RUNNING DESIRED TESTS |
|
38 | ##RUNNING DESIRED TESTS | |
36 | # nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account |
|
39 | # nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account | |
37 | # nosetests --pdb --pdb-failures |
|
40 | # nosetests --pdb --pdb-failures | |
38 | environ = {} |
|
41 | environ = {} | |
39 |
|
42 | |||
40 | #SOME GLOBALS FOR TESTS |
|
43 | #SOME GLOBALS FOR TESTS | |
41 | from tempfile import _RandomNameSequence |
|
44 | from tempfile import _RandomNameSequence | |
42 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) |
|
45 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) | |
43 | TEST_USER_ADMIN_LOGIN = 'test_admin' |
|
46 | TEST_USER_ADMIN_LOGIN = 'test_admin' | |
44 | TEST_USER_ADMIN_PASS = 'test12' |
|
47 | TEST_USER_ADMIN_PASS = 'test12' | |
45 | HG_REPO = 'vcs_test_hg' |
|
48 | HG_REPO = 'vcs_test_hg' | |
46 | GIT_REPO = 'vcs_test_git' |
|
49 | GIT_REPO = 'vcs_test_git' | |
47 |
|
50 | |||
48 | NEW_HG_REPO = 'vcs_test_hg_new' |
|
51 | NEW_HG_REPO = 'vcs_test_hg_new' | |
49 | NEW_GIT_REPO = 'vcs_test_git_new' |
|
52 | NEW_GIT_REPO = 'vcs_test_git_new' | |
50 |
|
53 | |||
51 | HG_FORK = 'vcs_test_hg_fork' |
|
54 | HG_FORK = 'vcs_test_hg_fork' | |
52 | GIT_FORK = 'vcs_test_git_fork' |
|
55 | GIT_FORK = 'vcs_test_git_fork' | |
53 |
|
56 | |||
54 | class TestController(TestCase): |
|
57 | class TestController(TestCase): | |
55 |
|
58 | |||
56 | def __init__(self, *args, **kwargs): |
|
59 | def __init__(self, *args, **kwargs): | |
57 | wsgiapp = pylons.test.pylonsapp |
|
60 | wsgiapp = pylons.test.pylonsapp | |
58 | config = wsgiapp.config |
|
61 | config = wsgiapp.config | |
59 |
|
62 | |||
60 | self.app = TestApp(wsgiapp) |
|
63 | self.app = TestApp(wsgiapp) | |
61 | url._push_object(URLGenerator(config['routes.map'], environ)) |
|
64 | url._push_object(URLGenerator(config['routes.map'], environ)) | |
62 | self.sa = meta.Session |
|
65 | self.sa = meta.Session | |
63 | self.index_location = config['app_conf']['index_dir'] |
|
66 | self.index_location = config['app_conf']['index_dir'] | |
64 | TestCase.__init__(self, *args, **kwargs) |
|
67 | TestCase.__init__(self, *args, **kwargs) | |
65 |
|
68 | |||
66 | def log_user(self, username=TEST_USER_ADMIN_LOGIN, |
|
69 | def log_user(self, username=TEST_USER_ADMIN_LOGIN, | |
67 | password=TEST_USER_ADMIN_PASS): |
|
70 | password=TEST_USER_ADMIN_PASS): | |
68 | response = self.app.post(url(controller='login', action='index'), |
|
71 | response = self.app.post(url(controller='login', action='index'), | |
69 | {'username':username, |
|
72 | {'username':username, | |
70 | 'password':password}) |
|
73 | 'password':password}) | |
71 |
|
74 | |||
72 | if 'invalid user name' in response.body: |
|
75 | if 'invalid user name' in response.body: | |
73 | self.fail('could not login using %s %s' % (username, password)) |
|
76 | self.fail('could not login using %s %s' % (username, password)) | |
74 |
|
77 | |||
75 | self.assertEqual(response.status, '302 Found') |
|
78 | self.assertEqual(response.status, '302 Found') | |
76 | self.assertEqual(response.session['rhodecode_user'].username, username) |
|
79 | self.assertEqual(response.session['rhodecode_user'].username, username) | |
77 | return response.follow() |
|
80 | return response.follow() | |
78 |
|
81 | |||
79 | def checkSessionFlash(self, response, msg): |
|
82 | def checkSessionFlash(self, response, msg): | |
80 | self.assertTrue('flash' in response.session) |
|
83 | self.assertTrue('flash' in response.session) | |
81 | self.assertTrue(msg in response.session['flash'][0][1]) |
|
84 | self.assertTrue(msg in response.session['flash'][0][1]) | |
82 |
|
85 |
@@ -1,61 +1,55 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 |
|
2 | |||
3 | class TestChangelogController(TestController): |
|
3 | class TestChangelogController(TestController): | |
4 |
|
4 | |||
5 | def test_index_hg(self): |
|
5 | def test_index_hg(self): | |
6 | self.log_user() |
|
6 | self.log_user() | |
7 | response = self.app.get(url(controller='changelog', action='index', |
|
7 | response = self.app.get(url(controller='changelog', action='index', | |
8 | repo_name=HG_REPO)) |
|
8 | repo_name=HG_REPO)) | |
9 |
|
9 | |||
10 | self.assertTrue("""<div id="chg_20" class="container">""" |
|
10 | self.assertTrue("""<div id="chg_20" class="container">""" | |
11 | in response.body) |
|
11 | in response.body) | |
12 | self.assertTrue("""<input class="changeset_range" id="5e204e7583b9" """ |
|
12 | self.assertTrue("""<input class="changeset_range" id="5e204e7583b9" """ | |
13 | """name="5e204e7583b9" type="checkbox" value="1" />""" |
|
13 | """name="5e204e7583b9" type="checkbox" value="1" />""" | |
14 | in response.body) |
|
14 | in response.body) | |
15 |
self.assertTrue("""<span>commit 154: 5e204e7583b9@2010-08- |
|
15 | self.assertTrue("""<span>commit 154: 5e204e7583b9@2010-08-09 """ | |
16 |
""" |
|
16 | """23:18:46</span>""" in response.body) | |
|
17 | ||||
17 | self.assertTrue("""Small update at simplevcs app""" in response.body) |
|
18 | self.assertTrue("""Small update at simplevcs app""" in response.body) | |
18 |
|
19 | |||
19 |
|
20 | |||
20 | self.assertTrue("""<span id="5e204e7583b9c8e7b93a020bd036564b1e""" |
|
21 | self.assertTrue("""<span id="5e204e7583b9c8e7b93a020bd036564b1e""" | |
21 | """731dae" class="changed_total tooltip" """ |
|
22 | """731dae" class="changed_total tooltip" """ | |
22 | """title="Affected number of files, click to """ |
|
23 | """title="Affected number of files, click to """ | |
23 | """show more details">3</span>""" in response.body) |
|
24 | """show more details">3</span>""" in response.body) | |
24 |
|
25 | |||
25 | #pagination |
|
26 | #pagination | |
26 |
|
||||
27 | response = self.app.get(url(controller='changelog', action='index', |
|
27 | response = self.app.get(url(controller='changelog', action='index', | |
28 | repo_name=HG_REPO), {'page':1}) |
|
28 | repo_name=HG_REPO), {'page':1}) | |
29 | response = self.app.get(url(controller='changelog', action='index', |
|
29 | response = self.app.get(url(controller='changelog', action='index', | |
30 | repo_name=HG_REPO), {'page':2}) |
|
30 | repo_name=HG_REPO), {'page':2}) | |
31 | response = self.app.get(url(controller='changelog', action='index', |
|
31 | response = self.app.get(url(controller='changelog', action='index', | |
32 | repo_name=HG_REPO), {'page':3}) |
|
32 | repo_name=HG_REPO), {'page':3}) | |
33 | response = self.app.get(url(controller='changelog', action='index', |
|
33 | response = self.app.get(url(controller='changelog', action='index', | |
34 | repo_name=HG_REPO), {'page':4}) |
|
34 | repo_name=HG_REPO), {'page':4}) | |
35 | response = self.app.get(url(controller='changelog', action='index', |
|
35 | response = self.app.get(url(controller='changelog', action='index', | |
36 | repo_name=HG_REPO), {'page':5}) |
|
36 | repo_name=HG_REPO), {'page':5}) | |
37 | response = self.app.get(url(controller='changelog', action='index', |
|
37 | response = self.app.get(url(controller='changelog', action='index', | |
38 | repo_name=HG_REPO), {'page':6}) |
|
38 | repo_name=HG_REPO), {'page':6}) | |
39 |
|
39 | |||
40 |
|
40 | |||
41 | # Test response after pagination... |
|
41 | # Test response after pagination... | |
42 | self.assertTrue("""<input class="changeset_range" id="46ad32a4f974" """ |
|
42 | self.assertTrue("""<input class="changeset_range" id="46ad32a4f974" """ | |
43 | """name="46ad32a4f974" type="checkbox" value="1" />""" |
|
43 | """name="46ad32a4f974" type="checkbox" value="1" />""" | |
44 | in response.body) |
|
44 | in response.body) | |
45 |
self.assertTrue("""<span>commit 64: 46ad32a4f974@2010-04- |
|
45 | self.assertTrue("""<span>commit 64: 46ad32a4f974@2010-04-19""" | |
46 |
""" |
|
46 | """ 22:33:21</span>"""in response.body) | |
47 |
|
47 | |||
48 | self.assertTrue("""<span id="46ad32a4f974e45472a898c6b0acb600320""" |
|
48 | self.assertTrue("""<span id="46ad32a4f974e45472a898c6b0acb600320""" | |
49 | """579b1" class="changed_total tooltip" """ |
|
49 | """579b1" class="changed_total tooltip" """ | |
50 | """title="Affected number of files, click to """ |
|
50 | """title="Affected number of files, click to """ | |
51 | """show more details">21</span>"""in response.body) |
|
51 | """show more details">21</span>"""in response.body) | |
52 | self.assertTrue("""<div class="message"><a href="/%s/changeset/""" |
|
52 | self.assertTrue("""<div class="message"><a href="/%s/changeset/""" | |
53 | """46ad32a4f974e45472a898c6b0acb600320579b1">""" |
|
53 | """46ad32a4f974e45472a898c6b0acb600320579b1">""" | |
54 | """Merge with 2e6a2bf9356ca56df08807f4ad86d48""" |
|
54 | """Merge with 2e6a2bf9356ca56df08807f4ad86d48""" | |
55 | """0da72a8f4</a></div>""" % HG_REPO in response.body) |
|
55 | """0da72a8f4</a></div>""" % HG_REPO in response.body) | |
56 |
|
||||
57 |
|
||||
58 |
|
||||
59 | #def test_index_git(self): |
|
|||
60 | # self.log_user() |
|
|||
61 | # response = self.app.get(url(controller='changelog', action='index', repo_name=GIT_REPO)) |
|
General Comments 0
You need to be logged in to leave comments.
Login now