def test__find_view_traversal_multiview(self): from zope.interface import implementer from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IMultiView from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() @implementer(IMultiView) class View1: pass request = dummy.DummyRequest() request.path_info = '/a' root = DefaultRootFactory(request) root_iface = providedBy(root) view = View1() registry.registerAdapter(view, (IViewClassifier, IRequest, root_iface), IMultiView, name='a') self._register_mapper(registry, []) command = self._makeOne(registry=registry) request = self._makeRequest('/a', registry) result = command._find_view(request) self.assertEqual(result, view)
def test__find_view_no_match_multiview_registered(self): from zope.interface import implementer from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IMultiView from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() @implementer(IMultiView) class View1(object): pass request = dummy.DummyRequest({'PATH_INFO': '/a'}) root = DefaultRootFactory(request) root_iface = providedBy(root) registry.registerAdapter(View1(), (IViewClassifier, IRequest, root_iface), IMultiView) self._register_mapper(registry, []) command = self._makeOne(registry=registry) request = self._makeRequest('/x', registry) result = command._find_view(request) self.assertEqual(result, None)
def test__find_view_traversal(self): from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IView from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() def view1(): pass request = dummy.DummyRequest({'PATH_INFO':'/a'}) root = DefaultRootFactory(request) root_iface = providedBy(root) registry.registerAdapter(view1, (IViewClassifier, IRequest, root_iface), IView, name='a') self._register_mapper(registry, []) command = self._makeOne(registry=registry) result = command._find_view('/a', registry) self.assertEqual(result, view1)
def test__find_view_traversal_multiview(self): from zope.interface import implements from zope.interface import providedBy from pyramid.interfaces import IRequest from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IMultiView from pyramid.traversal import DefaultRootFactory from pyramid.registry import Registry registry = Registry() class View1(object): implements(IMultiView) request = DummyRequest({'PATH_INFO': '/a'}) root = DefaultRootFactory(request) root_iface = providedBy(root) view = View1() registry.registerAdapter(view, (IViewClassifier, IRequest, root_iface), IMultiView, name='a') self._register_mapper(registry, []) command = self._makeOne() result = command._find_view('/a', registry) self.assertEqual(result, view)