def test_rootURLNotRedirectedWithLeafRoot(self): req = DummyRequest(['']) req.uri = '/' r = Leaf() site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, Leaf), res)
def test_404forStrangeResourceBecauseNoIndex(self): req = DummyRequest(['hello']) req.uri = '/hello' r = NonLeaf() hello = NonLeafWithChildChild() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, HelpfulNoResource), res) # Sanity check that child is accessible req2 = DummyRequest(['hello', 'child']) req2.uri = '/hello/child' res2 = site.getResourceFor(req2) self.assertTrue(isinstance(res2, RedirectingResource), res2) self.assertEqual("/hello/child/", res2._location)
def test_rootURLNotRedirectedWithNonLeafRoot(self): # the '' is necessary for this test, not for the above req = DummyRequest(['']) req.uri = '/' r = NonLeafWithIndexChild() site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, Leaf), res)
def test_404urlWithSlashCrud(self): req = DummyRequest(['hello', '', '', '']) req.uri = '/hello///' r = NonLeaf() hello = Leaf() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, HelpfulNoResource), res)
def test_404forBadPath(self): req = DummyRequest(['hello']) req.uri = '/hello' r = NonLeaf() nothello = Leaf() r.putChild('nothello', nothello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, HelpfulNoResource), res)
def test_notRedirectedBecauseResourceIsNotBetter2(self): # For non-leaf req = DummyRequest(['hello']) req.uri = '/hello' r = NonLeaf() hello = NonLeafPlainResource() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, NonLeafPlainResource), res)
def test_normalRequestNotRedirected(self): req = DummyRequest(['hello', '']) req.uri = '/hello/' r = NonLeaf() hello = Leaf() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, Leaf), res)
def test_normalRequestToNonLeafNonLeafNotRedirected(self): # ugh. need to do integration testing and send real requests req = DummyRequest(['hello', '', '']) req.uri = '/hello/' r = NonLeaf() hello = NonLeafWithNonLeafIndexChild() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, Leaf), res)
def test_redirectedToPathPlusSlash3(self): # For non-leaf -> non-leaf req = DummyRequest(['hello']) req.uri = '/hello' r = NonLeaf() hello = NonLeafWithNonLeafIndexChild() r.putChild('hello', hello) site = self._makeSite(r) res = site.getResourceFor(req) self.assertTrue(isinstance(res, RedirectingResource), res) self.assertEqual("/hello/", res._location)