MCPcopy Create free account
hub / github.com/EasyIME/PIME / get_app

Method get_app

python/python3/tornado/test/routing_test.py:183–220  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

181
182class RuleRouterTest(AsyncHTTPTestCase):
183 def get_app(self):
184 app = Application()
185
186 def request_callable(request):
187 request.connection.write_headers(
188 ResponseStartLine("HTTP/1.1", 200, "OK"),
189 HTTPHeaders({"Content-Length": "2"}),
190 )
191 request.connection.write(b"OK")
192 request.connection.finish()
193
194 router = CustomRouter()
195 router.add_routes(
196 {"/nested_handler": (app, _get_named_handler("nested_handler"))}
197 )
198
199 app.add_handlers(
200 ".*",
201 [
202 (
203 HostMatches("www.example.com"),
204 [
205 (
206 PathMatches("/first_handler"),
207 "tornado.test.routing_test.SecondHandler",
208 {},
209 "second_handler",
210 )
211 ],
212 ),
213 Rule(PathMatches("/.*handler"), router),
214 Rule(PathMatches("/first_handler"), FirstHandler, name="first_handler"),
215 Rule(PathMatches("/request_callable"), request_callable),
216 ("/connection_delegate", ConnectionDelegate()),
217 ],
218 )
219
220 return app
221
222 def test_rule_based_router(self):
223 response = self.fetch("/first_handler")

Callers

nothing calls this directly

Calls 9

add_routesMethod · 0.95
add_handlersMethod · 0.95
ApplicationClass · 0.90
HostMatchesClass · 0.90
PathMatchesClass · 0.90
RuleClass · 0.90
CustomRouterClass · 0.85
_get_named_handlerFunction · 0.85
ConnectionDelegateClass · 0.85

Tested by

no test coverage detected