From f179c23c705afc20026c26bd02d6ae64b8295935 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 14:39:58 -0800 Subject: Update quick_tutorial/cookiecutters.rst and related files --- docs/quick_tutorial/cookiecutters/cc_starter/tests.py | 10 ++++++++++ docs/quick_tutorial/cookiecutters/cc_starter/views/default.py | 2 +- docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'docs/quick_tutorial/cookiecutters/cc_starter') diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py index f3886be84..0891a3c51 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py @@ -16,6 +16,12 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'cc_starter') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py index 47af359b5..21c30e0b2 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py @@ -1,6 +1,6 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='cc_starter:templates/mytemplate.jinja2') def my_view(request): return {'project': 'cc_starter'} diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py index 69d6e2804..e8b8f26f3 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='cc_starter:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From f2320a274a7168916aeb40cdbc094c4911e5e747 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 19:21:59 -0800 Subject: Resync quick_tutorial/cookiecutters.rst and related files after moving tests directory --- .../cookiecutters/cc_starter/tests.py | 39 ---------------------- 1 file changed, 39 deletions(-) delete mode 100644 docs/quick_tutorial/cookiecutters/cc_starter/tests.py (limited to 'docs/quick_tutorial/cookiecutters/cc_starter') diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py deleted file mode 100644 index 0891a3c51..000000000 --- a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'cc_starter') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from cc_starter import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) -- cgit v1.2.3