adding the template tests

This commit is contained in:
Alfredo Deza
2011-03-06 15:21:29 -05:00
parent 888615d068
commit f36e41fc8d
2 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
from unittest import TestCase
import config
class TestConfigServer(TestCase):
def test_server_port(self):
assert config.server['port'] == '8080'
def test_server_host(self):
assert config.server['host'] == '0.0.0.0'
class TestConfigApp(TestCase):
def test_app_root(self):
root = config.app['root']
assert root.__class__.__name__ == 'RootController'
def test_app_modules(self):
assert len(config.app['modules']) == 1
def test_app_static_root(self):
assert config.app['static_root'] == 'public'
def test_app_template_path(self):
assert 'templates' in config.app['template_path']
def test_app_reload(self):
assert config.app['reload']
def test_app_debug(self):
assert config.app['debug']
def test_app_errors(self):
errors = {
'404' : '/error/404',
'__force_dict__' : True
}
assert config.app['errors'] == errors

View File

@@ -0,0 +1,25 @@
from unittest import TestCase
from webtest import TestApp
from pecan import make_app
from ${package}.controllers.root import RootController
class TestRootController(TestCase):
def setUp(self):
self.app = TestApp(
make_app(
RootController(),
template_path = '${package}/templates'
)
)
def test_get(self):
response = self.app.get('/')
assert response.status_int == 200
def test_get_not_found(self):
response = self.app.get('/a/bogus/url', expect_errors=True)
assert response.status_int == 404