Exemplo n.º 1
0
	def test_rootURLNotRedirectedWithLeafRoot(self):
		req = DummyRequest([''])
		req.uri = '/'

		r = Leaf()
		site = self._makeSite(r)
		res = site.getResourceFor(req)
		self.assertTrue(isinstance(res, Leaf), res)
Exemplo n.º 2
0
	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)
Exemplo n.º 3
0
	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)
Exemplo n.º 4
0
	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)
Exemplo n.º 5
0
	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)
Exemplo n.º 6
0
	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)
Exemplo n.º 7
0
	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)
Exemplo n.º 8
0
	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)
Exemplo n.º 9
0
	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)