adding the template tests
This commit is contained in:
41
pecan/templates/project/+package+/tests/test_config.py
Normal file
41
pecan/templates/project/+package+/tests/test_config.py
Normal 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
|
||||
25
pecan/templates/project/+package+/tests/test_root.py_tmpl
Normal file
25
pecan/templates/project/+package+/tests/test_root.py_tmpl
Normal 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
|
||||
Reference in New Issue
Block a user