Example #1
0
 def test_adaption(self):
     """
     A L{_SecureWrapper} constructed with an object which does not provide
     L{IResource} adapts it to L{IResource} and operates on the result.
     """
     notResource = NotResource()
     wrapper = _SecureWrapper(self.urlGenerator, notResource)
     self.assertTrue(isinstance(wrapper.wrappedResource, NotResourceAdapter))
     self.assertIdentical(wrapper.wrappedResource.notResource, notResource)
Example #2
0
 def test_adaption(self):
     """
     A L{_SecureWrapper} constructed with an object which does not provide
     L{IResource} adapts it to L{IResource} and operates on the result.
     """
     notResource = NotResource()
     wrapper = _SecureWrapper(self.urlGenerator, notResource)
     self.assertTrue(isinstance(wrapper.wrappedResource,
                                NotResourceAdapter))
     self.assertIdentical(wrapper.wrappedResource.notResource, notResource)
Example #3
0
 def test_notFound(self):
     """
     A L{_SecureWrapper.locateChild} lets L{NotFound} results from the
     wrapped resource pass through.
     """
     segments = ('foo', 'bar')
     request = FakeRequest()
     self.resource.childResource = None
     self.resource.childSegments = ()
     wrapper = _SecureWrapper(self.urlGenerator, self.resource)
     result = wrapper.locateChild(request, segments)
     def locatedChild(result):
         self.assertIdentical(result, NotFound)
     result.addCallback(locatedChild)
     return result
Example #4
0
 def test_childLocateChild(self):
     """
     L{_SecureWrapper.locateChild} returns a L{Deferred} which is called
     back with the result of the wrapped resource's C{locateChild} method
     wrapped in another L{_SecureWrapper}.
     """
     segments = ('foo', 'bar')
     request = FakeRequest()
     wrapper = _SecureWrapper(self.urlGenerator, self.resource)
     result = wrapper.locateChild(request, segments)
     def locatedChild((resource, segments)):
         self.assertTrue(isinstance(resource, _SecureWrapper))
         self.assertIdentical(resource.wrappedResource, self.child)
         self.assertEqual(segments, self.childSegments)
     result.addCallback(locatedChild)
     return result
Example #5
0
    def test_notFound(self):
        """
        A L{_SecureWrapper.locateChild} lets L{NotFound} results from the
        wrapped resource pass through.
        """
        segments = ('foo', 'bar')
        request = FakeRequest()
        self.resource.childResource = None
        self.resource.childSegments = ()
        wrapper = _SecureWrapper(self.urlGenerator, self.resource)
        result = wrapper.locateChild(request, segments)

        def locatedChild(result):
            self.assertIdentical(result, NotFound)

        result.addCallback(locatedChild)
        return result
Example #6
0
    def test_childLocateChild(self):
        """
        L{_SecureWrapper.locateChild} returns a L{Deferred} which is called
        back with the result of the wrapped resource's C{locateChild} method
        wrapped in another L{_SecureWrapper}.
        """
        segments = ('foo', 'bar')
        request = FakeRequest()
        wrapper = _SecureWrapper(self.urlGenerator, self.resource)
        result = wrapper.locateChild(request, segments)

        def locatedChild((resource, segments)):
            self.assertTrue(isinstance(resource, _SecureWrapper))
            self.assertIdentical(resource.wrappedResource, self.child)
            self.assertEqual(segments, self.childSegments)

        result.addCallback(locatedChild)
        return result