]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/tests/__init__.py
Make the built-in tests actually pass
[bluechips.git] / bluechips / tests / __init__.py
1 """Pylons application test package
2
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`
5 command.
6
7 This module initializes the application via ``websetup`` (`paster
8 setup-app`) and provides the base testing objects.
9 """
10 from unittest import TestCase
11
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
17
18 from bluechips import model
19 from bluechips.model import meta
20
21 __all__ = ['url_for', 'TestController']
22
23 def setup():
24     # Invoke websetup with the current config file
25     SetupCommand('setup-app').run([config['__file__']])
26     
27     test_user = model.User()
28     test_user.username = u'root'
29     test_user.name = u'Charlie Root'
30     test_user.resident = True
31     meta.Session.save(test_user)
32     meta.Session.commit()
33
34 def teardown():
35     meta.metadata.drop_all()
36
37 class TestController(TestCase):
38
39     def __init__(self, *args, **kwargs):
40         wsgiapp = loadapp('config:%s' % config['__file__'])
41         self.app = TestApp(wsgiapp)
42         TestCase.__init__(self, *args, **kwargs)