mò 0á¸Ec@s@dZdkZdkZedjo$eeiieiddƒƒndklZdk l Z dk l Z dk Z eiiƒeiidƒ\ZZd eeeifZd e ifd „ƒYZd e ifd „ƒYZdeifd„ƒYZdeiefd„ƒYZd„Zedjo eƒndS(s¡Example ZopeTestCase testing web access to a freshly started ZServer Note that we need to set up the error_log before starting the ZServer. Note further that the test thread needs to explicitly commit its transactions, so the ZServer threads can see modifications made to the ZODB. IF YOU THINK YOU NEED THE WEBSERVER STARTED YOU ARE PROBABLY WRONG! This is only required in very special cases, like when testing ZopeXMLMethods where XSLT processing is done by external tools that need to URL-call back into the Zope server. If you want to write functional unit tests, see the testFunctional.py example instead. $Id: testWebserver.py 30565 2005-05-30 22:07:11Z shh $ Nt__main__is framework.py(s ZopeTestCase(s transaction(s Unauthorizedishttp://%s:%d/%stManagementOpenercBstZdZd„ZRS(s Logs on as manager when promptedcCsdS(Ntmanagertsecret(smanagerR((tselfthosttrealm((tA/data/zmath/zope/lib/python/Testing/ZopeTestCase/testWebserver.pytprompt_user_passwd7s(t__name__t __module__t__doc__R(((RR5s tUnauthorizedOpenercBstZdZd„ZRS(s!Raises Unauthorized when promptedcCs td‚dS(Ns*The URLopener was asked for authentication(t Unauthorized(RRR((RR<s(R R R R(((RR :s t TestWebservercBs}tZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z d „Z d „ZRS(NcCsÍ|ii}|idddggƒ|iidddƒ|iidddƒx*tiD]}|ii i |dgƒq[W|ii d dd ƒ|i dƒi |ƒ}|iii|ƒtiƒdS( NRRtManagert index_htmltfilesindex_html calledt secret_htmlssecret_html calledt change_titlesW(Rtfoldert acl_userstuftuserFolderAddUsertaddDTMLDocumentt ZopeTestCasetstandard_permissionstpRtmanage_permissiont addDTMLMethodt getUserByIdt__of__RRtchangeOwnershipt transactiontcommit(RRRR((Rt afterSetUpBs    cCstiƒdS(N(R!R"(R((Rt beforeCloseZscCs)|ii|iƒ}|i|dƒdS(Nsindex_html called(RRRtpaget assertEqual(RR%((RttestAccessPublicObject^scCs9tƒt_titdƒiƒ}|i|dƒdS(Ns /index_htmlsindex_html called( Rturllibt _urlopenerturlopent folder_urltreadR%RR&(RR%((RttestURLAccessPublicObjectcs cCs)|ii|iƒ}|i|dƒdS(Nssecret_html called(RRRR%R&(RR%((RttestAccessProtectedObjectiscCs9tƒt_titdƒiƒ}|i|dƒdS(Ns /secret_htmlssecret_html called( RR(R)R*R+R,R%RR&(RR%((RttestURLAccessProtectedObjectns cCs;y|iidƒWn tj o|idƒnXdS(NRR (RRtrestrictedTraverseR tfail(R((RttestSecurityOfPublicObjecttscCsHtƒt_ytitdƒWn tj o|idƒnXdS(Ns /index_htmlR (R R(R)R*R+R RR1(R((RttestURLSecurityOfPublicObject|s  cCs;y|iidƒWntj onX|idƒdS(NRsResource not protected(RRR0R R1(R((RttestSecurityOfProtectedObject…s cCsHtƒt_ytitdƒWntj onX|idƒdS(Ns /secret_htmlsResource not protected(R R(R)R*R+R RR1(R((Rt testURLSecurityOfProtectedObjectŽs  cCsw|idgƒ|iiiddƒ|iii|ii|iiƒ}|i |dƒ|i |iii dƒdS(NRttitletFoo( RtsetRolestapptREQUESTtsetRRRR%R&R6(RR%((RttestModifyObject˜s cCs9tƒt_titdƒiƒ}|i|dƒdS(Ns"/index_html/change_title?title=FooR7( RR(R)R*R+R,R%RR&(RR%((RttestURLModifyObject¡s cCs|i|iiƒtƒdS(N(RR&Rt absolute_urlR+(R((RttestAbsoluteURL§s(R R R#R$R'R-R.R/R2R3R4R5R<R=R?(((RR@s        tTestSandboxedWebservercBs tZdZd„Zd„ZRS(s†Demonstrates that tests involving ZServer threads can also be run from sandboxes. In fact, it may be preferable to do so. cCs:tƒt_titdƒ|i|iii dƒdS(Ns"/index_html/change_title?title=FooR7( RR(R)R*R+RR&RRR6(R((RttestConnectionIsShared´s cCs0d|i_tiƒd|i_tiƒdS(Nii(RRtfooR!R"(R((Rt testCanCommit¼s   (R R R RARC(((RR@¬s  cCsFdkl}l}|ƒ}|i|tƒƒ|i|tƒƒ|S(N(s TestSuites makeSuite(tunittestt TestSuitet makeSuitetsuitetaddTestRR@(RERFRG((Rt test_suiteÅs  (R tostsysR texecfiletpathtjointTestingRtTesting.ZopeTestCaseR!t AccessControlR R(tutilstsetupSiteErrorLogt startZServerRtportt folder_nameR+tFancyURLopenerRR Rt SandboxedR@RIt framework(R!RR RRR@R+R(RKR RRIRJRU((Rt?s" $     l