Ejemplo n.º 1
0
 def test_invalid_file(self):
     # If the file does not exist, /index.html is returned.
     req = FakeRequest('/missingfile.html')
     handler = RewritingHTTPRequestHandler(req, self.addr, None)
     handler.path = req.path
     resp = handler.do_GET()
     self.assertEqual('/index.html', resp)
Ejemplo n.º 2
0
 def test_valid_file(self):
     # Can serve up an existing file.
     with open('somefile.html', 'w'):
         req = FakeRequest('/somefile.html')
         handler = RewritingHTTPRequestHandler(req, self.addr, None)
         handler.path = req.path
         resp = handler.do_GET()
         self.assertEqual('/somefile.html', resp)
Ejemplo n.º 3
0
 def test_invalid_path(self):
     # If the path does not exist, /index.html is returned.
     subdir = tempfile.mkdtemp(dir=self.tempdir)
     dirname = os.path.split(subdir)[-1]
     fn = os.path.join(dirname, 'missingfile.html')
     path = '/' + fn
     req = FakeRequest(path)
     handler = RewritingHTTPRequestHandler(req, self.addr, None)
     handler.path = req.path
     resp = handler.do_GET()
     self.assertEqual('/index.html', resp)
Ejemplo n.º 4
0
 def test_valid_path(self):
     # Can serve up an existing path.
     subdir = tempfile.mkdtemp(dir=self.tempdir)
     dirname = os.path.split(subdir)[-1]
     fn = os.path.join(dirname, 'somefile.html')
     with open(fn, 'w'):
         path = '/' + fn
         req = FakeRequest(path)
         handler = RewritingHTTPRequestHandler(req, self.addr, None)
         handler.path = req.path
         resp = handler.do_GET()
         self.assertEqual(path, resp)