From f36e41fc8d3a8417f715f751fdb79264fcdd96c5 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Sun, 6 Mar 2011 15:21:29 -0500 Subject: [PATCH] adding the template tests --- .../project/+package+/tests/test_config.py | 41 +++++++++++++++++++ .../project/+package+/tests/test_root.py_tmpl | 25 +++++++++++ 2 files changed, 66 insertions(+) create mode 100644 pecan/templates/project/+package+/tests/test_config.py create mode 100644 pecan/templates/project/+package+/tests/test_root.py_tmpl diff --git a/pecan/templates/project/+package+/tests/test_config.py b/pecan/templates/project/+package+/tests/test_config.py new file mode 100644 index 0000000..eff4425 --- /dev/null +++ b/pecan/templates/project/+package+/tests/test_config.py @@ -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 diff --git a/pecan/templates/project/+package+/tests/test_root.py_tmpl b/pecan/templates/project/+package+/tests/test_root.py_tmpl new file mode 100644 index 0000000..0fd16f0 --- /dev/null +++ b/pecan/templates/project/+package+/tests/test_root.py_tmpl @@ -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