From 916f88578ad68470a35a4b7afd223e9dbf5fd20d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 18 May 2009 07:07:12 +0000 Subject: Features -------- - Added a ``traverse`` function to the ``repoze.bfg.traversal`` module. This function may be used to retrieve certain values computed during path resolution. See the Traversal API chapter of the documentation for more information about this function. Deprecations ------------ - Internal: ``ITraverser`` callables should now return a dictionary rather than a tuple. Up until 0.7.0, all ITraversers were assumed to return a 3-tuple. In 0.7.1, ITraversers were assumed to return a 6-tuple. As (by evidence) it's likely we'll need to add further information to the return value of an ITraverser callable, 0.8 assumes that an ITraverser return a dictionary with certain elements in it. See the ``repoze.bfg.interfaces.ITraverser`` interface for the list of keys that should be present in the dictionary. ``ITraversers`` which return tuples will still work, although a deprecation warning will be issued. Backwards Incompatibilities --------------------------- - If your code used the ITraverser interface directly (not via an API function such as ``find_model``) via an adapter lookup, you'll need to change your code to expect a dictionary rather than a 3- or 6-tuple if your code ever gets return values from the default ModelGraphTraverser or RoutesModelTraverser adapters. --- repoze/bfg/tests/test_testing.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'repoze/bfg/tests/test_testing.py') diff --git a/repoze/bfg/tests/test_testing.py b/repoze/bfg/tests/test_testing.py index d61092065..504151ce2 100644 --- a/repoze/bfg/tests/test_testing.py +++ b/repoze/bfg/tests/test_testing.py @@ -41,8 +41,20 @@ class TestTestingFunctions(unittest.TestCase): from zope.component import getAdapter from repoze.bfg.interfaces import ITraverserFactory adapter = getAdapter(None, ITraverserFactory) - self.assertEqual(adapter({'PATH_INFO':'/ob1'}), (ob1, '', [])) - self.assertEqual(adapter({'PATH_INFO':'/ob2'}), (ob2, '', [])) + result = adapter({'PATH_INFO':'/ob1'}) + self.assertEqual(result['context'], ob1) + self.assertEqual(result['view_name'], '') + self.assertEqual(result['subpath'], []) + self.assertEqual(result['traversed'], [u'ob1']) + self.assertEqual(result['vroot'], ob1) + self.assertEqual(result['vroot_path'], []) + result = adapter({'PATH_INFO':'/ob2'}) + self.assertEqual(result['context'], ob2) + self.assertEqual(result['view_name'], '') + self.assertEqual(result['subpath'], []) + self.assertEqual(result['traversed'], [u'ob2']) + self.assertEqual(result['vroot'], ob2) + self.assertEqual(result['vroot_path'], []) self.assertRaises(KeyError, adapter, {'PATH_INFO':'/ob3'}) from repoze.bfg.traversal import find_model self.assertEqual(find_model(None, '/ob1'), ob1) -- cgit v1.2.3