K i{"ddlmZmZmZmZddlmZmZmZm Z m Z m Z ddl m Z ddlmZmZmZddlmZddlZGdde ZGd d e ZiZGd d eZGd deZGdde ZGdde ZdZedZedZGddeZGdde Z GddeZ!Gdde Z"Gdde Z#y) ) HTTPHeadersHTTPMessageDelegateHTTPServerConnectionDelegateResponseStartLine) HostMatches PathMatchesReversibleRouterRouterRule RuleRouter)AsyncHTTPTestCase) Application HTTPErrorRequestHandler) WSGIContainerNceZdZdZy) BasicRouterc DGddt}||jS)NceZdZdZdZy)1BasicRouter.find_handler..MessageDelegatec||_yN connectionselfrs _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/test/routing_test.py__init__z:BasicRouter.find_handler..MessageDelegate.__init__% ",c|jjtdddtddid|jj yNHTTP/1.1OKContent-Length2OK)r write_headersrrfinishrs rr*z8BasicRouter.find_handler..MessageDelegate.finish(sC--%j#t<!13 78 &&(r N__name__ __module__ __qualname__rr*r rMessageDelegater$s  - )r r1)rr)rrequestkwargsr1s r find_handlerzBasicRouter.find_handler#s" )1 )w1122r N)r-r.r/r4r0r rrr"s 3r rceZdZdZdZy)BasicRouterTestCasectSr)rr+s rget_appzBasicRouterTestCase.get_app4s }r c^|jd}|j|jdy)Nz /any_requestr(fetch assertEqualbodyrresponses rtest_basic_routerz%BasicRouterTestCase.test_basic_router7s$::n- .r N)r-r.r/r8r@r0r rr6r63s /r r6ceZdZdZy) GetResourcecZ|tvr td|jt|y)N) resourcesrr*rpaths rgetzGetResource.get@s$ y C.  IdO$r Nr-r.r/rHr0r rrBrB?s%r rBceZdZdZy) PostResourcec>|jjt|<yr)r2r=rErFs rpostzPostResource.postHs,,++ $r N)r-r.r/rMr0r rrKrKGs,r rKceZdZdZdZy)HTTPMethodRouterc||_yr)app)rrQs rrzHTTPMethodRouter.__init__Ms r c |jdk(rtnt}|jj |||j gS)NGET) path_args)methodrBrKrQget_handler_delegaterG)rr2r3handlers rr4zHTTPMethodRouter.find_handlerPs6!(5!8+lxx,,Wg',,,XXr N)r-r.r/rr4r0r rrOrOLs Yr rOceZdZdZdZy)HTTPMethodRouterTestCasec(ttSr)rOrr+s rr8z HTTPMethodRouterTestCase.get_appVs ..r cP|jddd}|j|jd|jd}|j|jd|jd}|j|jd|j|jdy) Nz/post_resourcePOSTdata)rUr=r$z /get_resourcerDsdata)r;r<coder=r>s rtest_http_method_routerz0HTTPMethodRouterTestCase.test_http_method_routerYs::.vF:K ,::o. ,::./ , 0r N)r-r.r/r8r_r0r rrYrYUs / 1r rYc*Gfddt}|S)NceZdZfdZy)#_get_named_handler..Handlerc|jjjd+|j|jjddz|j dz|j zy)Napp_namez: ) applicationsettingsrHwriter* reverse_url)rargsr3 handler_names rrHz'_get_named_handler..Handler.getgsc((,,Z8D 4++44Z@4GH KK t+d.>.>|.LL Mr NrI)rjsrHandlerrbfs  Nr rk)r)rjrks` r_get_named_handlerrlesN.N Nr first_handlersecond_handlerc0eZdZfdZdZdZdZxZS) CustomRouterc0t|i|_yr)superrroutes)r __class__s rrzCustomRouter.__init__us  r c:|jj|yr)rsupdate)rrss r add_routeszCustomRouter.add_routesys 6"r c |j|jvr.|j|j\}}|j||Syr)rGrsrV)rr2r3rQrWs rr4zCustomRouter.find_handler|s@ <<4;; &;;w||4LC++GW= = 'r c0d|z}||jvr|SdS)N/)rs)rnameri handler_paths rrhzCustomRouter.reverse_urls!Tz +t{{:|DDr )r-r.r/rrwr4rh __classcell__)rts@rrprpts#> Er rpceZdZdZdZy)CustomRouterTestCasectGfddt}|d}|d}j|tf|tf|tfdS)NceZdZfdZy)7CustomRouterTestCase.get_app..CustomApplicationc*j|g|Sr)rh)rr{rirouters rrhzCCustomRouterTestCase.get_app..CustomApplication.reverse_urls)v))$666r N)r-r.r/rh)rsrCustomApplicationrs 7r rapp1)rdapp2)/first_handler/second_handler/first_handler_second_app)rprrw FirstHandler SecondHandler)rrrrrs @rr8zCustomRouterTestCase.get_apps^ 7  7!&1 &1#'"6$(-#8.2L-A   r c|jd}|j|jd|jd}|j|jd|jd}|j|jdy)Nrs#app1: first_handler: /first_handlerrs%app2: second_handler: /second_handlerrs#app2: first_handler: /first_handlerr:r>s rtest_custom_routerz'CustomRouterTestCase.test_custom_routersn::./ (NO::/0 (PQ::9: (NOr N)r-r.r/r8rr0r rrrs (Pr rceZdZdZy)ConnectionDelegatec0Gddt}||S)NceZdZdZdZy)9ConnectionDelegate.start_request..MessageDelegatec||_yrrrs rrzBConnectionDelegate.start_request..MessageDelegate.__init__rr c d}|jjtdddtdt t |i|jj ||jjy)Nr(r#r$r%r&)rr)rrstrlenrgr*)r response_bodys rr*z@ConnectionDelegate.start_request..MessageDelegate.finishsa % --%j#t<!13s=7I3J KL%%m4&&(r Nr,r0r rr1rs  - )r r1)r)r server_conn request_connr1s r start_requestz ConnectionDelegate.start_requests )1 )|,,r N)r-r.r/rr0r rrrs-r rceZdZdZdZy)RuleRouterTestc bt}d}t}|jd|tdfi|j dt dt ddidfgftt d |tt dtd tt d |d tfg|S)Nc|jjtdddtddi|jj d|jj yr")rr)rrrgr*)r2s rrequest_callablez0RuleRouterTest.get_app..request_callablesX    , ,!*c48-s34     $ $U +    % % 'r /nested_handlernested_handlerz.*www.example.comrz'tornado.test.routing_test.SecondHandlerrnz /.*handlerrm)r{/request_callable/connection_delegate) rrprwrl add_handlersrrr rr)rrQrrs rr8zRuleRouterTest.get_appsm ( &89I&J K L    12((89E,  [.7[!12LW[!457GH');)=>  * r c|jd}|j|jd|jdddi}|j|jd|jd}|j|jd|jd }|j|jd |jd }|j|jd |jd }|j|jd |jd}|j|jd y)Nrsfirst_handler: /first_handlerHostr)headersssecond_handler: /first_handlerrsnested_handler: /nested_handlerz/nested_not_found_handlerrDrr(r/404)r;r<r=r^r>s rtest_rule_based_routerz%RuleRouterTest.test_rule_based_routers::./ (HI::.AR8S:T (IJ::/0 (JK::9: ,::45 .::12 .::f% ,r N)r-r.r/r8rr0r rrrs %N-r rc$eZdZdZdZdZdZy)WSGIContainerTestCasec t|j}Gddt}tt dt d|idfgft d|fgS)NceZdZdZy).WSGIContainerTestCase.get_app..HandlercD|j|jdy)Ntornado)r*rh)rrir3s rrHz2WSGIContainerTestCase.get_app..Handler.gets D,,Y78r NrIr0r rrkrs 9r rkz /tornado.* /tornado/testr/wsgi)rwsgi_apprr rr)rrrks rr8zWSGIContainerTestCase.get_appsc / 9n 9 -"2GR!K LMW%x0    r c|dgdgS)Nz200 OKWSGIr0)renvironstart_responses rrzWSGIContainerTestCase.wsgi_appsx$yr c|jd}|j|jd|jd}|j|jdy)Nrs /tornado/testrrr:r>s rtest_wsgi_containerz)WSGIContainerTestCase.test_wsgi_container sG::o. (89::g& 0r c^|jd}|j|jdy)NrrD)r;r<r^r>s rtest_delegate_not_foundz-WSGIContainerTestCase.test_delegate_not_founds$::f% ,r N)r-r.r/r8rrrr0r rrrs "1-r r)$tornado.httputilrrrrtornado.routingrrr r r r tornado.testingr tornado.webrrr tornado.wsgirtypingrr6rErBrKrOrYrlrrrprrrrr0r rrs .>>& 3&3"/+/  %.%,>, YvY 10 1 "/2 "#34 E#E$P,P<-5-$<-&<-~---r