Ñò ÏyIc @ sÎ d Z d d k l Z l Z l Z l Z l Z d d d d g Z d e f d „ ƒ YZ d e f d „ ƒ YZ d e f d „ ƒ YZ d e e f d „ ƒ YZ d e f d „ ƒ YZ d e e f d „ ƒ YZ d S( s" Utilities to test source adapters.iÿÿÿÿ( t SourceErrort ExistingSectionErrort NonExistingSectionErrort ItemPresentErrort ItemNotPresentErrort GroupsAdapterTestert PermissionsAdapterTestert ReadOnlyGroupsAdapterTestert ReadOnlyPermissionsAdapterTestert _ReadOnlyBaseAdapterTesterc B sq e Z d Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( s% Base test case for read-only adaptersc C s1 t ƒ } x! | i i ƒ D] } | | O} q W| S( N( t sett all_sectionst values( t selft all_itemst items( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt _get_all_items s c C sE t g } | i i ƒ D]$ \ } } | | j o | | q q ~ ƒ S( N( R R R ( R t itemt _[1]t nt s( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt _get_item_sections% s c C s | i | i i ƒ | i ƒ d S( N( t assertEqualt adaptert _get_all_sectionsR ( R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_retrieving_all_sections( s c C s@ x9 | i i ƒ D]( \ } } | i | i i | ƒ | ƒ q Wd S( N( R R R R t _get_section_items( R t section_nameR ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_getting_section_items+ s c C s x | i i ƒ D] } q Wd S( N( R t keys( R R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_checking_existing_section0 s c C s d } d S( Nu i_dont_exist( ( R R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt" test_checking_non_existing_section5 s c C sA x: | i i ƒ D]) \ } } x | i i | ƒ D] } q/ Wq Wd S( N( R R R R ( R R R R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_checking_item_inclusion: s c C s3 | i i ƒ } x | i i ƒ D] \ } } q Wd S( N( t new_itemst popR R ( R t excluded_itemR R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt% test_checking_excluded_item_inclusionA s c C s x | i i ƒ D] } q Wd S( N( R R ( R R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_checking_section_existenceI s c C s d } d S( Nu designers( ( R t invalid_section( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt, test_checking_non_existing_section_existenceN s c C s d S( N( ( R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_sets_if_it_is_writableS s ( t __name__t __module__t __doc__R R R R R R R R$ R% R' R( ( ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyR s t _BaseAdapterTesterc B s2 e Z d Z d „ Z d „ Z d „ Z d „ Z RS( s( Base test case for read & write adaptersc C sG x@ | i i ƒ D]/ \ } } | i i | | i ƒ | | i B} q Wd S( N( R R R t _include_itemsR! ( R R R t final_items( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt! test_adding_many_items_to_section\ s c C s d } | i i | ƒ d S( Nu cool-section( R t _create_section( R t section( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_creating_sectionc s c C s0 | i i ƒ d } d } | i i | | ƒ d S( Ni u cool-section( R R R t _edit_section( R t old_sectiont new_section( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_editing_sectioni s c C s' | i i ƒ d } | i i | ƒ d S( Ni ( R R R t _delete_section( R R1 ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt test_deleting_sectionr s ( R) R* R+ R/ R2 R6 R8 ( ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyR, Y s c B s> e Z d Z e d ƒ Z d „ Z d „ Z d „ Z d „ Z RS( 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. u guidou rasmusc C sH h t d ƒ d 6t d ƒ d 6t d ƒ d 6t ƒ d 6t ƒ d 6| _ d S( Nu rmsu adminsu linusu developersu sballmeru trollsu pythonu php( u rms( u rmsu linus( u sballmer( R R ( R ( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt setUp¢ s c C s h | d 6S( 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. s repoze.what.userid( ( R t userid( ( sA /usr/lib/python2.6/site-packages/repoze/what/adapters/testutil.pyt _make_credentials« s c C sO xH | i ƒ D]: } | i | ƒ } | i | i i | ƒ | i | ƒ ƒ q Wd S( N( R R; R R t _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 c C s2 | i d ƒ } | i | i i | ƒ t ƒ ƒ d S( Nu gustavo( R; R R R<