Test suite runs and passes!
[zzz-floof.git] / floof / 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.script.appinstall import SetupCommand
14 from pylons import config, url
15 from routes.util import URLGenerator
16 from webtest import TestApp
17
18 import pylons.test
19 from elixir import *
20 from floof.model import *
21 from floof.model import meta
22 from floof import model as model
23 from sqlalchemy import engine_from_config
24
25 __all__ = ['environ', 'url', 'TestController', 'TestModel']
26
27
28 # Invoke websetup with the current config file
29 # SetupCommand('setup-app').run([config['__file__']])
30
31 # additional imports ...
32 import os
33 from paste.deploy import appconfig
34 from floof.config.environment import load_environment
35
36 here_dir = os.path.dirname(__file__)
37 conf_dir = os.path.dirname(os.path.dirname(here_dir))
38
39 test_file = os.path.join(conf_dir, 'test.ini')
40 conf = appconfig('config:' + test_file)
41 load_environment(conf.global_conf, conf.local_conf)
42 environ = {}
43
44 engine = elixir.metadata.bind
45
46
47 def setup():
48 """Setup for the entire test suite."""
49 setup_all(create_tables=True)
50 pass
51
52 def teardown():
53 """Teardown for the entire test suite."""
54 drop_all(engine)
55 pass
56
57
58 class TestModel(TestCase):
59 def setUp(self):
60 pass
61
62 def tearDown(self):
63 pass
64
65
66 class TestController(TestCase):
67
68 def setUp(self):
69 """Setup for a controller test class.
70 """
71 pass
72
73 def tearDown(self):
74 """Teardown for a controller test class.
75 """
76 pass
77
78 def __init__(self, *args, **kwargs):
79 if pylons.test.pylonsapp:
80 wsgiapp = pylons.test.pylonsapp
81 else:
82 wsgiapp = loadapp('config:%s' % config['__file__'])
83 self.app = TestApp(wsgiapp)
84 url._push_object(URLGenerator(config['routes.map'], environ))
85 TestCase.__init__(self, *args, **kwargs)