summaryrefslogtreecommitdiff
path: root/docs/narr/MyProject/myproject
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2014-11-26 14:59:20 -0500
committerTres Seaver <tseaver@palladion.com>2014-11-26 14:59:20 -0500
commite9189222be26d7b4979f5af12efa3a269835a332 (patch)
treeaa2d045d7fc12556ee92473421587950b4d7a241 /docs/narr/MyProject/myproject
parent782eb470cf4b31c2cab75f3cc14a5f9c42eeb9f0 (diff)
parent9c94e129f1bbb753317deba7ea5f790db13e0709 (diff)
downloadpyramid-e9189222be26d7b4979f5af12efa3a269835a332.tar.gz
pyramid-e9189222be26d7b4979f5af12efa3a269835a332.tar.bz2
pyramid-e9189222be26d7b4979f5af12efa3a269835a332.zip
Merge pull request #1467 from mgrbyte/fix.issue1001
Include code examples for integration and functional tests in docs.
Diffstat (limited to 'docs/narr/MyProject/myproject')
-rw-r--r--docs/narr/MyProject/myproject/tests.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/narr/MyProject/myproject/tests.py b/docs/narr/MyProject/myproject/tests.py
index 64dcab1d5..8c60407e5 100644
--- a/docs/narr/MyProject/myproject/tests.py
+++ b/docs/narr/MyProject/myproject/tests.py
@@ -15,3 +15,40 @@ class ViewTests(unittest.TestCase):
request = testing.DummyRequest()
info = my_view(request)
self.assertEqual(info['project'], 'MyProject')
+
+class ViewIntegrationTests(unittest.TestCase):
+ def setUp(self):
+ """ This sets up the application registry with the
+ registrations your application declares in its ``includeme``
+ function.
+ """
+ self.config = testing.setUp()
+ self.config.include('myproject')
+
+ def tearDown(self):
+ """ Clear out the application registry """
+ testing.tearDown()
+
+ def test_my_view(self):
+ from myproject.views import my_view
+ request = testing.DummyRequest()
+ result = my_view(request)
+ self.assertEqual(result.status, '200 OK')
+ body = result.app_iter[0]
+ self.assertTrue('Welcome to' in body)
+ self.assertEqual(len(result.headerlist), 2)
+ self.assertEqual(result.headerlist[0],
+ ('Content-Type', 'text/html; charset=UTF-8'))
+ self.assertEqual(result.headerlist[1], ('Content-Length',
+ str(len(body))))
+
+class FunctionalTests(unittest.TestCase):
+ def setUp(self):
+ from myproject import main
+ app = main({})
+ from webtest import TestApp
+ self.testapp = TestApp(app)
+
+ def test_root(self):
+ res = self.testapp.get('/', status=200)
+ self.assertTrue('Pyramid' in res.body)