diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-04-30 03:57:57 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-04-30 03:57:57 +0000 |
| commit | 013c4bc7b3337bc50794300d7cb8502d191f4490 (patch) | |
| tree | 06c8f873748444225e0f3667f432a20cf338af9c /repoze/bfg/tests | |
| parent | 361e49d1bd5bb498710d70c1122ff6feef589f95 (diff) | |
| download | pyramid-013c4bc7b3337bc50794300d7cb8502d191f4490.tar.gz pyramid-013c4bc7b3337bc50794300d7cb8502d191f4490.tar.bz2 pyramid-013c4bc7b3337bc50794300d7cb8502d191f4490.zip | |
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.
Diffstat (limited to 'repoze/bfg/tests')
| -rw-r--r-- | repoze/bfg/tests/test_traversal.py | 43 |
1 files changed, 2 insertions, 41 deletions
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 |
