summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests/test_integration.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-10-18 02:27:43 +0000
committerChris McDonough <chrism@agendaless.com>2009-10-18 02:27:43 +0000
commit2cce431f02a37c119eacfc3dfa94af9fe3305de1 (patch)
treef154dbf4937afb3f5d08ed497f6c4cac6f843144 /repoze/bfg/tests/test_integration.py
parentf276669b505cb0565dcf854f2e0e751151ccf836 (diff)
downloadpyramid-2cce431f02a37c119eacfc3dfa94af9fe3305de1.tar.gz
pyramid-2cce431f02a37c119eacfc3dfa94af9fe3305de1.tar.bz2
pyramid-2cce431f02a37c119eacfc3dfa94af9fe3305de1.zip
- More than one ``@bfg_view`` decorator may now be stacked on top of
any number of others. Each invocation of the decorator registers a single view. For instance, the following combination of decorators and a function will register two views:: from repoze.bfg.view import bfg_view @bfg_view(name='edit') @bfg_view(name='change') def edit(context, request): pass This makes it possible to associate more than one view configuration for a single callable without requiring ZCML.
Diffstat (limited to 'repoze/bfg/tests/test_integration.py')
-rw-r--r--repoze/bfg/tests/test_integration.py119
1 files changed, 59 insertions, 60 deletions
diff --git a/repoze/bfg/tests/test_integration.py b/repoze/bfg/tests/test_integration.py
index 5e386a069..691d64e24 100644
--- a/repoze/bfg/tests/test_integration.py
+++ b/repoze/bfg/tests/test_integration.py
@@ -105,68 +105,43 @@ class TestGrokkedApp(unittest.TestCase):
from repoze.bfg.interfaces import IView
from repoze.bfg.interfaces import IRequest
import repoze.bfg.tests.grokkedapp as package
- actions = zcml_configure('configure.zcml', package)[-10:]
+
+ actions = zcml_configure('configure.zcml', package)
actions.sort()
- action = actions[0]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], '')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[1]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], '')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[2]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'another')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[3]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'another')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[4]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'another_grokked_class')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[5]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'another_grokked_instance')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[6]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'another_oldstyle_grokked_class')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[7]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'grokked_class')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[8]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'grokked_instance')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
-
- action = actions[9]
- self.assertEqual(action[0][1], None)
- self.assertEqual(action[0][2], 'oldstyle_grokked_class')
- self.assertEqual(action[0][3], IRequest)
- self.assertEqual(action[0][4], IView)
+ num = 18
+
+ action_names = [actions[x][0][2] for x in range(len(actions[:num]))]
+ action_types = [(actions[x][0][1],
+ actions[x][0][3],
+ actions[x][0][4]) for x in range(len(actions[:num]))]
+
+ for typ in action_types:
+ self.assertEqual(typ, (None, IRequest, IView))
+
+ self.assertEqual(
+ action_names, [
+ '',
+ '',
+ 'another',
+ 'another',
+ 'another_grokked_class',
+ 'another_grokked_instance',
+ 'another_oldstyle_grokked_class',
+ 'another_stacked1',
+ 'another_stacked2',
+ 'another_stacked_class1',
+ 'another_stacked_class2',
+ 'grokked_class',
+ 'grokked_instance',
+ 'oldstyle_grokked_class',
+ 'stacked1',
+ 'stacked2',
+ 'stacked_class1',
+ 'stacked_class2',
+ ]
+ )
+
ctx = DummyContext()
req = DummyRequest()
@@ -207,6 +182,30 @@ class TestGrokkedApp(unittest.TestCase):
'another_oldstyle_grokked_class')
self.assertEqual(result, 'another_oldstyle_grokked_class')
+ result = render_view_to_response(ctx, req, 'stacked1')
+ self.assertEqual(result, 'stacked')
+
+ result = render_view_to_response(ctx, req, 'stacked2')
+ self.assertEqual(result, 'stacked')
+
+ result = render_view_to_response(ctx, req, 'another_stacked1')
+ self.assertEqual(result, 'another_stacked')
+
+ result = render_view_to_response(ctx, req, 'another_stacked2')
+ self.assertEqual(result, 'another_stacked')
+
+ result = render_view_to_response(ctx, req, 'stacked_class1')
+ self.assertEqual(result, 'stacked_class')
+
+ result = render_view_to_response(ctx, req, 'stacked_class2')
+ self.assertEqual(result, 'stacked_class')
+
+ result = render_view_to_response(ctx, req, 'another_stacked_class1')
+ self.assertEqual(result, 'another_stacked_class')
+
+ result = render_view_to_response(ctx, req, 'another_stacked_class2')
+ self.assertEqual(result, 'another_stacked_class')
+
class DummyContext(object):
pass