1 """Pylons application test package
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`
7 This module initializes the application via ``websetup`` (`paster
8 setup-app`) and provides the base testing objects.
10 from unittest import TestCase
12 from paste.deploy import loadapp
13 from paste.fixture import TestApp
14 from paste.script.appinstall import SetupCommand
15 from pylons import config
16 from routes import url_for
18 from bluechips import model
19 from bluechips.model import meta
21 __all__ = ['url_for', 'TestController', 'sample_users']
23 sample_users = [u'Alice', u'Bob', u'Charlie', u'Dave', u'Eve']
26 # Invoke websetup with the current config file
27 SetupCommand('setup-app').run([config['__file__']])
29 test_user = model.User()
30 test_user.username = u'root'
31 test_user.name = u'Charlie Root'
32 test_user.resident = True
33 meta.Session.save(test_user)
36 def tearDownPackage():
37 meta.metadata.drop_all()
39 class TestController(TestCase):
41 def __init__(self, *args, **kwargs):
42 wsgiapp = loadapp('config:%s' % config['__file__'])
43 self.app = TestApp(wsgiapp)
44 TestCase.__init__(self, *args, **kwargs)