summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-01-21 01:49:28 +0000
committerChris McDonough <chrism@agendaless.com>2010-01-21 01:49:28 +0000
commit688d01dba826ed5ce98580da06082be5dc64e09f (patch)
tree26f67cbb7ba80d8d3364066a26302365ca9f4530 /repoze/bfg/tests
parent1a74dc000993f39a430b6c37d775bb664e86a3ac (diff)
downloadpyramid-688d01dba826ed5ce98580da06082be5dc64e09f.tar.gz
pyramid-688d01dba826ed5ce98580da06082be5dc64e09f.tar.bz2
pyramid-688d01dba826ed5ce98580da06082be5dc64e09f.zip
- Fix a view lookup ordering bug whereby a view with a larger number
of predicates registered first (literally first, not "earlier") for a triad would lose during view lookup to one registered with fewer.
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_configuration.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_configuration.py b/repoze/bfg/tests/test_configuration.py
index db960e2e9..b8b114fb9 100644
--- a/repoze/bfg/tests/test_configuration.py
+++ b/repoze/bfg/tests/test_configuration.py
@@ -1030,6 +1030,31 @@ class ConfiguratorTests(unittest.TestCase):
request = self._makeRequest(config)
self._assertNotFound(wrapper, None, request)
+ def test_add_view_custom_predicate_bests_standard_predicate(self):
+ view = lambda *arg: 'OK'
+ view2 = lambda *arg: 'NOT OK'
+ config = self._makeOne()
+ def pred1(context, request):
+ return True
+ config.add_view(view=view, custom_predicates=(pred1,))
+ config.add_view(view=view2, request_method='GET')
+ wrapper = self._getViewCallable(config)
+ request = self._makeRequest(config)
+ request.method = 'GET'
+ self.assertEqual(wrapper(None, request), 'OK')
+
+ def test_add_view_custom_more_preds_first_bests_fewer_preds_last(self):
+ view = lambda *arg: 'OK'
+ view2 = lambda *arg: 'NOT OK'
+ config = self._makeOne()
+ config.add_view(view=view, request_method='GET', xhr=True)
+ config.add_view(view=view2, request_method='GET')
+ wrapper = self._getViewCallable(config)
+ request = self._makeRequest(config)
+ request.method = 'GET'
+ request.is_xhr = True
+ self.assertEqual(wrapper(None, request), 'OK')
+
def _assertRoute(self, config, name, path, num_predicates=0):
from repoze.bfg.interfaces import IRoutesMapper
mapper = config.registry.getUtility(IRoutesMapper)