def testNoMatch(self): self.StartWebServer(filters.match_path('/exact')) self.CheckError('/', expected_code=404) self.CheckError('/blar', expected_code=404) self.CheckError('/exacta', expected_code=404) self.CheckError('/exact/a', expected_code=404)
def testMatch(self): def application(environ, start_response): content = '%s %s' % (environ['PATH_INFO.0'], environ.get('HTTP_X.1') is None) return filters.static_page(content)(environ, start_response) self.StartWebServer(filters.match_path(r'/exact([0-9]?)', app=application)) response = self.SendRequest('/exact') self.CheckResponse(response, expected_content=' True') response = self.SendRequest('/exact1') self.CheckResponse(response, expected_content='1 True') response = self.SendRequest('/exact2') self.CheckResponse(response, expected_content='2 True')