From 013c4bc7b3337bc50794300d7cb8502d191f4490 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 30 Apr 2009 03:57:57 +0000 Subject: Make ModelGraphTraverser assume that all traversed objects provide ILocation. Make WrappingModelGraphTraverser assume that *no* traversed objects provide ILocation. This makes it unnecessary to explain why the root object in a WrappingModelGraphTraverser setup needs to supply the ILocation interface. Now it doesn't. --- repoze/bfg/tests/test_traversal.py | 43 ++------------------------------------ 1 file changed, 2 insertions(+), 41 deletions(-) (limited to 'repoze/bfg/tests') diff --git a/repoze/bfg/tests/test_traversal.py b/repoze/bfg/tests/test_traversal.py index 3354dcce1..942f84684 100644 --- a/repoze/bfg/tests/test_traversal.py +++ b/repoze/bfg/tests/test_traversal.py @@ -195,17 +195,12 @@ class WrappingModelGraphTraverserTests(ModelGraphTraverserTests): from repoze.bfg.traversal import WrappingModelGraphTraverser return WrappingModelGraphTraverser - def test_call_with_ILocation_root_proxies(self): + def test_call_proxies(self): baz = DummyContext() bar = DummyContext(baz) foo = DummyContext(bar) root = DummyContext(foo) - from zope.interface import directlyProvides - from repoze.bfg.interfaces import ILocation from zope.proxy import isProxy - directlyProvides(root, ILocation) - root.__name__ = None - root.__parent__ = None policy = self._makeOne(root) environ = self._getEnviron(PATH_INFO='/foo/bar/baz') ctx, name, subpath, traversed, vroot, vroot_path = policy(environ) @@ -221,47 +216,13 @@ class WrappingModelGraphTraverserTests(ModelGraphTraverserTests): self.failUnless(isProxy(ctx.__parent__.__parent__)) self.assertEqual(ctx.__parent__.__parent__.__name__, 'foo') self.assertEqual(ctx.__parent__.__parent__.__parent__, root) - self.failIf(isProxy(ctx.__parent__.__parent__.__parent__)) + self.failUnless(isProxy(ctx.__parent__.__parent__.__parent__)) self.assertEqual(ctx.__parent__.__parent__.__parent__.__name__, None) self.assertEqual(ctx.__parent__.__parent__.__parent__.__parent__, None) self.assertEqual(traversed, [u'foo', u'bar', u'baz']) self.assertEqual(vroot, root) self.assertEqual(vroot_path, []) - def test_call_with_ILocation_root_proxies_til_next_ILocation(self): - # This is a test of an insane setup; it tests the case where - # intermediate objects (foo and bar) do not implement - # ILocation, and so are returned as proxies to the traverser, - # but when we reach the "baz" object, it *does* implement - # ILocation, and its parent should be the *real* "bar" object - # rather than the proxied bar. - from zope.interface import directlyProvides - from repoze.bfg.interfaces import ILocation - baz = DummyContext() - directlyProvides(baz, ILocation) - baz.__name__ = 'baz' - bar = DummyContext(baz) - baz.__parent__ = bar - foo = DummyContext(bar) - root = DummyContext(foo) - from zope.proxy import isProxy - directlyProvides(root, ILocation) - root.__name__ = None - root.__parent__ = None - policy = self._makeOne(root) - environ = self._getEnviron(PATH_INFO='/foo/bar/baz') - ctx, name, subpath, traversed, vroot, vroot_path = policy(environ) - self.assertEqual(name, '') - self.assertEqual(subpath, []) - self.assertEqual(ctx, baz) - self.failIf(isProxy(ctx)) - self.assertEqual(ctx.__name__, 'baz') - self.assertEqual(ctx.__parent__, bar) - self.failIf(isProxy(ctx.__parent__)) - self.assertEqual(traversed, [u'foo', u'bar', u'baz']) - self.assertEqual(vroot, root) - self.assertEqual(vroot_path, []) - class FindInterfaceTests(unittest.TestCase): def _callFUT(self, context, iface): from repoze.bfg.traversal import find_interface -- cgit v1.2.3