Permalink
Browse files

add test_home

  • Loading branch information...
Philipp Litzenberger
Philipp Litzenberger committed Nov 1, 2013
1 parent ea83020 commit 7dfd4f970b9f64b482ee59c3ae814dec495b0a2f
Showing with 19 additions and 6 deletions.
  1. +19 −6 demo/demo/tests.py
View
@@ -1,16 +1,29 @@
import unittest
from pyramid import testing
+from pyramid_layout.layout import LayoutManager
+from .layouts import AppLayout
+
class ViewTests(unittest.TestCase):
def setUp(self):
- self.config = testing.setUp()
+ self.request = testing.DummyRequest()
+ self.context = testing.DummyResource()
+ self.config = testing.setUp(request=self.request)
+ self.config.include('pyramid_layout')
+ self.request.layout_manager = LayoutManager(self.context, self.request)
+ self.request.layout_manager.layout = AppLayout(self.context, self.request)
def tearDown(self):
testing.tearDown()
- def test_my_view(self):
- from .views import my_view
- request = testing.DummyRequest()
- info = my_view(request)
- self.assertEqual(info['project'], 'demo')
+ def test_home(self):
+ from .views import home
+ headings = self.request.layout_manager.layout.headings
+ self.assertEqual(len(headings), 0)
+ home(self.request)
+ new_headings = [h[0] for h in headings]
+ self.assertEqual(len(headings), 3)
+ self.assertIn('heading-mako', new_headings)
+ self.assertIn('heading-chameleon', new_headings)
+ self.assertIn('heading-jinja2', new_headings)

0 comments on commit 7dfd4f9

Please sign in to comment.