m 0Ec@sdZdkZdkZedjo$eeiieiddndklZei ddk l Z dk l Z d gZ d gZd Zd Zd ZdZdeifdYZdZedjo endS(spExample ZopeTestCase testing a PythonScript in the default fixture This test module demonstrates the security API of ZopeTestCase. Note that you are encouraged to call any of the following methods to modify the test user's security credentials: setRoles() setPermissions() login() logout() $Id: testPythonScript.py 66141 2006-03-23 18:58:35Z shh $ Nt__main__is framework.py(s ZopeTestCaset PythonScripts(s Unauthorized(sgetSecurityManagersView management screenssChange Python Scriptssa=1sreturn atas return a+1tTestPythonScriptcBstZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZRS(s5Tries various things allowed by the ZopeTestCase API.cCsD|iid}|id|id|_|iittdS(s1Adds a PythonScript object to the default fixtureRtpsN( tselftfoldertmanage_addProductt dispatchertmanage_addPythonScriptRtZPythonScript_editt ps_params1tps_body1(RR((tD/data/zmath/zope/lib/python/Testing/ZopeTestCase/testPythonScript.pyt afterSetUp3s  cCs{|it|id|i|iitd|i|iit |ii }|i|i t idS(NRs (Rt failUnlessthasattrRt assertEqualRtbodyR tparamsR tgetOwnertownert getUserNamet ZopeTestCaset user_name(RR((R t testSetup<s cCs|i|idddS(Ni(RRR(R((R ttestCanCallScript1WithArgumentFscCs|i|iddS(Ni(RRR(R((R t!testCanCallScript1WithoutArgumentJscCs0|iitt|i|idddS(Nii(RRR t ps_params2tps_body2R(R((R ttestCanCallScript2WithArgumentNscCs-|iitt|it|ifdS(N(RRR RRt assertRaisest TypeError(R((R t$testCannotCallScript2WithoutArgumentSscCs|it|iiddS(Nt manage_main(RRt UnauthorizedRtrestrictedTraverse(R((R t'testCannotAccessWithoutAccessPermissionZscCsH|ity|iidWn tj o|idnXdS(NR"s Access to manage_main was denied(RtsetPermissionstaccess_permissionsRR$R#tfail(R((R t!testCanAccessWithAccessPermission^s  cCs'|i|it|iiddS(NR"(RtlogoutRR#RR$(R((R ttestCannotAccessIfAnonymousfs cCsK|idgy|iidWn tj o|idnXdS(NtManagerR"s+Access to manage_main was denied to Manager(RtsetRolesRR$R#R((R((R ttestCanAccessIfManagerks cCs2|itti|i|id|iidS(NR"(RRR#tgetSecurityManagertvalidateRR"(R((R t6testCannotAccessWithoutAccessPermissionSecurityManageruscCs]|ity)ti|i|id|iiWn tj o|idnXdS(NR"s Access to manage_main was denied( RR&R'R/R0RR"R#R((R((R t0testCanAccessWithAccessPermissionSecurityManagerzs  )cCs<|i|itti|i|id|iidS(NR"(RR*RR#R/R0RR"(R((R t*testCannotAccessIfAnonymousSecurityManagers cCs`|idgy)ti|i|id|iiWn tj o|idnXdS(NR,R"s+Access to manage_main was denied to Manager(RR-R/R0RR"R#R((R((R t%testCanAccessIfManagerSecurityManagers )cCswy|iidttWntj onBX|i|iitdd|i|iitdddS(NR s s$ZPythonScript_edit was not protecteds<ZPythonScript_edit was protected but no exception was raised( RRR$RRR#RRR (R((R t%testCannotEditWithoutChangePermissionscCs|ity|iidttWn tj o|idn8X|i |ii td|i |ii tdS(NR s'Access to ZPythonScript_edit was denieds ( RR&tchange_permissionsRR$RRR#R(RRR(R((R ttestCanEditWithChangePermissions cCs|iy|iidttWntj onBX|i|iitdd|i|iit dddS(NR s s$ZPythonScript_edit was not protecteds<ZPythonScript_edit was protected but no exception was raised( RR*RR$RRR#RRR (R((R ttestCannotEditIfAnonymouss cCs|idgy|iidttWn tj o|idn8X|i|ii td|i|ii tdS(NR,R s2Access to ZPythonScript_edit was denied to Managers ( RR-RR$RRR#R(RRR(R((R ttestCanEditIfManagers(t__name__t __module__t__doc__RRRRRR!R%R)R+R.R1R2R3R4R5R7R8R9(((R R0s&            cCs3dkl}l}|}|i|t|S(N(s TestSuites makeSuite(tunittestt TestSuitet makeSuitetsuitetaddTestR(R>R?R@((R t test_suites (R<tostsysR:texecfiletpathtjointTestingRtinstallProductt AccessControlR#R/R'R6R R RRRRBt framework( R6RR#RRR/R RDRRBR'RCR ((R t?s" $