Ñò Ï­yIc@sÎdZddklZlZlZlZlZddddgZdefd„ƒYZ d e fd „ƒYZ de fd „ƒYZ de e fd „ƒYZ de fd „ƒYZ de e fd„ƒYZdS(s"Utilities to test source adapters.iÿÿÿÿ(t SourceErrortExistingSectionErrortNonExistingSectionErrortItemPresentErrortItemNotPresentErrortGroupsAdapterTestertPermissionsAdapterTestertReadOnlyGroupsAdapterTestert ReadOnlyPermissionsAdapterTestert_ReadOnlyBaseAdapterTestercBsqeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( s%Base test case for read-only adapterscCs1tƒ}x!|iiƒD]}||O}qW|S(N(tsett all_sectionstvalues(tselft all_itemstitems((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt_get_all_itemss  cCsEtg}|iiƒD]$\}}||jo ||qq~ƒS(N(R R R(R titemt_[1]tnts((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt_get_item_sections%scCs |i|iiƒ|iƒdS(N(t assertEqualtadaptert_get_all_sectionsR (R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_retrieving_all_sections(scCs@x9|iiƒD](\}}|i|ii|ƒ|ƒqWdS(N(R RRRt_get_section_items(R t section_nameR((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_getting_section_items+s cCs?x8|iiƒD]'}|ii|ƒptd|‚qWdS(NsSection "%s" does NOT exist(R tkeysRt_section_existstAssertionError(R R((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_checking_existing_section0scCs,d}|ii|ƒ ptd|‚dS(Nu i_dont_existsSection "%s" DOES exist(RRR(R R((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt"test_checking_non_existing_section5scCskxd|iiƒD]S\}}xD|ii|ƒD]0}|ii||ƒptd||f‚q/WqWdS(Ns*Item "%s" must be included in section "%s"(R RRRt_item_is_includedR(R RRR((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_checking_item_inclusion:s cCs^|iiƒ}xH|iiƒD]7\}}|ii||ƒ ptdt|f‚qWdS(Ns+Item "%s" must not included in section "%s"(t new_itemstpopR RRR"RR(R t excluded_itemRR((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt%test_checking_excluded_item_inclusionAs  cCs?x8|iiƒD]'}|ii|ƒptd|‚qWdS(NsSection "%s" must exist(R RRRR(R R((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_checking_section_existenceIscCs,d}|ii|ƒ ptd|‚dS(Nu designerssSection "%s" must not exist(RRR(R tinvalid_section((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt,test_checking_non_existing_section_existenceNscCs!t|idƒp td‚dS(Nt is_writables^The adapter doesn't have the 'is_writable' attribute; please call its parent's constructor too(thasattrRR(R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_sets_if_it_is_writableSs(t__name__t __module__t__doc__RRRRR R!R#R'R(R*R-(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyR s          t_BaseAdapterTestercBs2eZdZd„Zd„Zd„Zd„ZRS(s(Base test case for read & write adapterscCswxp|iiƒD]_\}}|ii||iƒ||iB}|ii|ƒ|jptd||if‚qWdS(Ns"%s" does not include %s(R RRt_include_itemsR$RR(R RRt final_items((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt!test_adding_many_items_to_section\s   cCsDd}|ii|ƒ||iiƒiƒjptd|‚dS(Nu cool-sectionsSection "%s" could not be added(Rt_create_sectionRRR(R tsection((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_creating_sectioncscCs||iiƒd}d}|ii||ƒ||iiƒiƒjo||iiƒiƒjptd||f‚dS(Niu cool-sections$Section "%s" was not renamed to "%s"(R RRt _edit_sectionRR(R t old_sectiont new_section((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_editing_sectioniscCsQ|iiƒd}|ii|ƒ||iiƒiƒjptd|‚dS(NisSection "%s" was not deleted(R RRt_delete_sectionRR(R R6((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_deleting_sectionrs(R.R/R0R4R7R;R=(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyR1Ys    cBs>eZdZedƒZd„Zd„Zd„Zd„ZRS(s> Test case for read-only groups source adapters. The groups source used for the tests must only contain the following groups (aka "sections") and their relevant users (aka "items"; if any): * admins * rms * developers * rms * linus * trolls * sballmer * python * php .. attribute:: adapter An instance of the :term:`group adapter` to be tested. For example, a test case for the mock group adapter ``FakeReadOnlyGroupSourceAdapter`` may look like this:: from repoze.what.adapters.testutil import ReadOnlyGroupsAdapterTester class TestReadOnlyGroupsAdapterTester(ReadOnlyGroupsAdapterTester, unittest.TestCase): def setUp(self): super(TestReadOnlyGroupsAdapterTester, self).setUp() self.adapter = FakeReadOnlyGroupSourceAdapter() .. note:: :class:`GroupsAdapterTester` extends this test case to check write operations. uguidourasmuscCsHhtd ƒd6td ƒd6td ƒd6tƒd6tƒd6|_dS( Nurmsuadminsulinusu developersusballmerutrollsupythonuphp(urms(urmsulinus(usballmer(R R (R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pytsetUp¢s     cCs h|d6S(sù Return a fake :mod:`repoze.what` ``credentials`` dictionary based on the ``userid``. Overwrite this method if its generated ``credentials`` dictionaries are not suitable for your adapter. srepoze.what.userid((R tuserid((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt_make_credentials«s cCsOxH|iƒD]:}|i|ƒ}|i|ii|ƒ|i|ƒƒq WdS(N(RR@RRt_find_sectionsR(R R?t credentials((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt)test_finding_groups_of_authenticated_user¶s  cCs2|idƒ}|i|ii|ƒtƒƒdS(Nugustavo(R@RRRAR (R RB((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt(test_finding_groups_of_non_existing_user¼s(uguidourasmus( R.R/R0R R$R>R@RCRD(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyRys %  cBseZdZd„ZRS(s„ Test case for groups source adapters. This test case extends :class:`ReadOnlyGroupsAdapterTester` to test write operations in read & write adapters and it should be set up the same way as its parent. For example, a test case for the mock group adapter ``FakeGroupSourceAdapter`` may look like this:: from repoze.what.adapters.testutil import GroupsAdapterTester class TestGroupsAdapterTester(GroupsAdapterTester, unittest.TestCase): def setUp(self): super(TestGroupsAdapterTester, self).setUp() self.adapter = FakeGroupSourceAdapter() cCsSd}d}|ii||ƒ|ii|ƒtƒjptd||f‚dS(Nu developersurmsulinuss"%s" still includes %s(urmsulinus(Rt_exclude_itemsRR R(R tgrouptusers((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt#test_removing_many_users_from_groupÓs (R.R/R0RH(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyRÁscBs5eZdZedƒZd„Zd„Zd„ZRS(sŠ Test case for read-only permissions source adapters. The permissions source used for the tests must only contain the following permissions (aka "sections") and their relevant groups (aka "items"; if any): * see-site * trolls * edit-site * admins * developers * commit * developers .. attribute:: adapter An instance of the :term:`permission adapter` to be tested. For example, a test case for the mock permission adapter defined above (``FakeReadOnlyPermissionSourceAdapter``) may look like this:: from repoze.what.adapters.testutil import ReadOnlyPermissionsAdapterTester class TestReadOnlyPermissionsAdapterTester(ReadOnlyPermissionsAdapterTester, unittest.TestCase): def setUp(self): super(TestReadOnlyPermissionsAdapterTester, self).setUp() self.adapter = FakeReadOnlyPermissionSourceAdapter() .. note:: :class:`PermissionsAdapterTester` extends this test case to check write operations. upythonuphpcCs4htdƒd6tdƒd6td ƒd6|_dS( Nutrollsusee-siteuadminsu developersu edit-siteucommit(utrolls(uadminsu developers(u developers(R R (R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyR>s  cCs@x9|iƒD]+}|i|ii|ƒ|i|ƒƒq WdS(N(RRRRAR(R RF((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyttest_finding_permissions s cCs#|i|iidƒtƒƒdS(Nu designers(RRRAR (R ((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt.test_finding_permissions_of_non_existing_groups(upythonuphp(R.R/R0R R$R>RIRJ(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyRÛs $   cBseZdZd„ZRS(sa Test case for permissions source adapters. This test case extends :class:`ReadOnlyPermissionsAdapterTester` to test write operations in read & write adapters and it should be set up the same way as its parent. For example, a test case for the mock group adapter ``FakePermissionSourceAdapter`` may look like this: For example, a test case for the mock permission adapter defined above (``FakePermissionSourceAdapter``) may look like this:: from repoze.what.adapters.testutil import PermissionsAdapterTester class TestPermissionsAdapterTester(PermissionsAdapterTester, unittest.TestCase): def setUp(self): super(TestPermissionsAdapterTester, self).setUp() self.adapter = FakePermissionSourceAdapter() cCsSd}d}|ii||ƒ|ii|ƒtƒjptd||f‚dS(Nu edit-siteuadminsu developerss"%s" still includes %s(uadminsu developers(RRERR R(R t permissiontgroups((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt&test_deying_permisssion_to_many_groups*s (R.R/R0RM(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyRsN(R0trepoze.what.adaptersRRRRRt__all__tobjectR R1RRRR(((sA/usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyts( = H8