annotate rhodecode/tests/__init__.py @ 688:8acbfa837180 beta

Tests rewrite for 1.2 added some globals configs to make tests easier. Fixed search index_location to take from configuration files now fixed git http_user_agent bug
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 14 Nov 2010 17:24:32 +0100
parents b75b77ef649d
children 51127b2efb33
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 """
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
10 from unittest import TestCase
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
11
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12 from paste.deploy import loadapp
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 from paste.script.appinstall import SetupCommand
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 from pylons import config, url
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
15 from routes.util import URLGenerator
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
16 from webtest import TestApp
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
17 import os
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 535
diff changeset
18 from rhodecode.model import meta
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
19 import logging
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
20
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
21
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
22 log = logging.getLogger(__name__)
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
23
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 import pylons.test
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
25
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
26 __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO',
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
27 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', ]
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
28
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
29 # Invoke websetup with the current 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
30 #SetupCommand('setup-app').run([config_file])
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
31
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
32 ##RUNNING DESIRED TESTS
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 535
diff changeset
33 #nosetests rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
34
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
35 environ = {}
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
36
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
37 #SOME GLOBALS FOR TESTS
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 TESTS_TMP_PATH = '/tmp'
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
39
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
40 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
41 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
42
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
43 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
44 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
45
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
46 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
47 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
48
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
49 class TestController(TestCase):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
50
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
51 def __init__(self, *args, **kwargs):
459
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
52 wsgiapp = pylons.test.pylonsapp
7c978511c951 implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents: 0
diff changeset
53 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
54
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
55 self.app = TestApp(wsgiapp)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
56 url._push_object(URLGenerator(config['routes.map'], environ))
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 459
diff changeset
57 self.sa = meta.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
58 self.index_location = config['app_conf']['index_dir']
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
59 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
60
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 491
diff changeset
61 def log_user(self, username='test_admin', password='test12'):
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
62 response = self.app.post(url(controller='login', action='index'),
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
63 {'username':username,
fefffd6fd5f4 Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
64 'password':password})
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
65 print response
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
66
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
67 if 'invalid user name' in response.body:
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
68 assert False, '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
69
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
70 assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
71 assert response.session['rhodecode_user'].username == username, 'wrong logged in user got %s expected %s' % (response.session['rhodecode_user'].username, username)
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
72 return response.follow()