Blame | Last modification | View Log | RSS feed
# -*- coding: utf-8 -*-"""Unit and functional test suite for Wiki-20."""from os import pathimport sysfrom tg import configfrom paste.deploy import loadappfrom paste.script.appinstall import SetupCommandfrom routes import url_forfrom webtest import TestAppfrom nose.tools import eq_from wiki20 import model__all__ = ['setup_db', 'teardown_db', 'TestController', 'url_for']def setup_db():"""Method used to build a database"""engine = config['pylons.app_globals'].sa_enginemodel.init_model(engine)model.metadata.create_all(engine)def teardown_db():"""Method used to destroy a database"""engine = config['pylons.app_globals'].sa_enginemodel.metadata.drop_all(engine)class TestController(object):"""Base functional test case for the controllers.The Wiki-20 application instance (``self.app``) set up in this testcase (and descendants) has authentication disabled, so that developers cantest the protected areas independently of the :mod:`repoze.who` pluginsused initially. This way, authentication can be tested once and separately.Check wiki20.tests.functional.test_authentication for the repoze.whointegration tests.This is the officially supported way to test protected areas withrepoze.who-testutil (http://code.gustavonarea.net/repoze.who-testutil/)."""application_under_test = 'main_without_authn'def setUp(self):"""Method called by nose before running each test"""# Loading the application:conf_dir = config.herewsgiapp = loadapp('config:test.ini#%s' % self.application_under_test,relative_to=conf_dir)self.app = TestApp(wsgiapp)# Setting it up:test_file = path.join(conf_dir, 'test.ini')cmd = SetupCommand('setup-app')cmd.run([test_file])def tearDown(self):"""Method called by nose after running each test"""# Cleaning up the database:teardown_db()