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