[Checkins] SVN: zope.app.authentication/trunk/ Use zope.component's provideAdapter/Utility/Handler functions instead of zope.app.testing's ztapi ones.

Dan Korostelev nadako at gmail.com
Thu Aug 20 04:30:43 EDT 2009


Log message for revision 102984:
  Use zope.component's provideAdapter/Utility/Handler functions instead of zope.app.testing's ztapi ones.

Changed:
  U   zope.app.authentication/trunk/CHANGES.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/README.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt
  U   zope.app.authentication/trunk/src/zope/app/authentication/tests.py

-=-
Modified: zope.app.authentication/trunk/CHANGES.txt
===================================================================
--- zope.app.authentication/trunk/CHANGES.txt	2009-08-20 08:07:34 UTC (rev 102983)
+++ zope.app.authentication/trunk/CHANGES.txt	2009-08-20 08:30:43 UTC (rev 102984)
@@ -7,7 +7,10 @@
 
 * Fix ftesting.zcml due to ``zope.securitypolicy`` update.
 
+* Don't use ``zope.app.testing.ztapi`` in tests, use zope.component's
+  testing functions instead.
 
+
 3.6.0 (2009-03-14)
 ------------------
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/README.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/README.txt	2009-08-20 08:07:34 UTC (rev 102983)
+++ zope.app.authentication/trunk/src/zope/app/authentication/README.txt	2009-08-20 08:30:43 UTC (rev 102984)
@@ -197,7 +197,7 @@
 
   >>> def add_info(event):
   ...     event.principal.title = event.info.title
-  >>> subscribe([interfaces.IAuthenticatedPrincipalCreated], None, add_info)
+  >>> provideHandler(add_info, [interfaces.IAuthenticatedPrincipalCreated])
 
 Now, if we authenticate a principal, its title is set::
 
@@ -459,7 +459,7 @@
 principal created events to add information to the newly created principal.
 In this case, we need to subscribe to IFoundPrincipalCreated events::
 
-  >>> subscribe([interfaces.IFoundPrincipalCreated], None, add_info)
+  >>> provideHandler(add_info, [interfaces.IFoundPrincipalCreated])
 
 Now when a principal is created as a result of a search, it's title and
 description will be set (by the add_info handler function).

Modified: zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt	2009-08-20 08:07:34 UTC (rev 102983)
+++ zope.app.authentication/trunk/src/zope/app/authentication/browser/schemasearch.txt	2009-08-20 08:30:43 UTC (rev 102984)
@@ -3,13 +3,15 @@
 
 Placefull setup for making the search plugin IPhysicallyLocatable::
 
-  >>> from zope.app.testing import ztapi
+  >>> from zope.component import provideAdapter
   >>> from zope.schema.interfaces import ITextLine
+  >>> from zope.publisher.interfaces.browser import IDefaultBrowserLayer
   >>> from zope.app.form.browser import TextWidget
   >>> from zope.app.form.interfaces import IInputWidget
   >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
   >>> site = placefulSetUp(True)
-  >>> ztapi.browserView(ITextLine, '', TextWidget, providing=IInputWidget)
+  >>> provideAdapter(TextWidget, (ITextLine, IDefaultBrowserLayer),
+  ... IInputWidget)
 
 If a plugin supports `IQuerySchemaSearch`::
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt	2009-08-20 08:07:34 UTC (rev 102983)
+++ zope.app.authentication/trunk/src/zope/app/authentication/groupfolder.txt	2009-08-20 08:30:43 UTC (rev 102984)
@@ -88,14 +88,14 @@
 when principals are created. In order for `setGroupsForPrincipal` to find out
 group folder, we have to register it as a utility:
 
-  >>> from zope.app.testing import ztapi
   >>> from zope.app.authentication.interfaces import IAuthenticatorPlugin
-  >>> ztapi.provideUtility(IAuthenticatorPlugin, groups)
+  >>> from zope.component import provideUtility
+  >>> provideUtility(groups, IAuthenticatorPlugin)
 
 We will create and register a new principals utility:
 
   >>> principals = Principals(groups)
-  >>> ztapi.provideUtility(IAuthentication, principals)
+  >>> provideUtility(principals, IAuthentication)
 
 Now we can set the principals on the group:
 
@@ -300,8 +300,7 @@
   ...     interface.implements(zope.authentication.interfaces.IEveryoneGroup)
 
   >>> everybody = EverybodyGroup('all')
-  >>> ztapi.provideUtility(zope.authentication.interfaces.IEveryoneGroup,
-  ...                      everybody)
+  >>> provideUtility(everybody, zope.authentication.interfaces.IEveryoneGroup)
 
 Then the group will be added to the principal:
 
@@ -316,8 +315,7 @@
   ...         zope.authentication.interfaces.IAuthenticatedGroup)
 
   >>> authenticated = AuthenticatedGroup('auth')
-  >>> ztapi.provideUtility(zope.authentication.interfaces.IAuthenticatedGroup,
-  ...                      authenticated)
+  >>> provideUtility(authenticated, zope.authentication.interfaces.IAuthenticatedGroup)
 
 Then the group will be added to the principal:
 

Modified: zope.app.authentication/trunk/src/zope/app/authentication/tests.py
===================================================================
--- zope.app.authentication/trunk/src/zope/app/authentication/tests.py	2009-08-20 08:07:34 UTC (rev 102983)
+++ zope.app.authentication/trunk/src/zope/app/authentication/tests.py	2009-08-20 08:30:43 UTC (rev 102984)
@@ -21,11 +21,11 @@
 
 from zope.testing import doctest
 from zope.interface import implements
-from zope.component import provideUtility, provideAdapter
+from zope.component import provideUtility, provideAdapter, provideHandler
 from zope.component.eventtesting import getEvents, clearEvents
 from zope.publisher.interfaces import IRequest
 
-from zope.app.testing import placelesssetup, ztapi
+from zope.app.testing import placelesssetup
 from zope.app.testing.setup import placefulSetUp, placefulTearDown
 from zope.session.interfaces import \
         IClientId, IClientIdManager, ISession, ISessionDataContainer
@@ -50,20 +50,20 @@
 
 def sessionSetUp(session_data_container_class=PersistentSessionDataContainer):
     placelesssetup.setUp()
-    ztapi.provideAdapter(IRequest, IClientId, TestClientId)
-    ztapi.provideAdapter(IRequest, ISession, Session)
-    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
+    provideAdapter(TestClientId, [IRequest], IClientId)
+    provideAdapter(Session, [IRequest], ISession)
+    provideUtility(CookieClientIdManager(), IClientIdManager)
     sdc = session_data_container_class()
-    ztapi.provideUtility(ISessionDataContainer, sdc, '')
+    provideUtility(sdc, ISessionDataContainer, '')
 
 def nonHTTPSessionTestCaseSetUp(sdc_class=PersistentSessionDataContainer):
     # I am getting an error with ClientId and not TestClientId
     placelesssetup.setUp()
-    ztapi.provideAdapter(IRequest, IClientId, ClientId)
-    ztapi.provideAdapter(IRequest, ISession, Session)
-    ztapi.provideUtility(IClientIdManager, CookieClientIdManager())
+    provideAdapter(ClientId, [IRequest], IClientId)
+    provideAdapter(Session, [IRequest], ISession)
+    provideUtility(CookieClientIdManager(), IClientIdManager)
     sdc = sdc_class()
-    ztapi.provideUtility(ISessionDataContainer, sdc, '')
+    provideUtility(sdc, ISessionDataContainer, '')
 
 
 class NonHTTPSessionTestCase(unittest.TestCase):
@@ -114,9 +114,9 @@
                              tearDown=siteTearDown,
                              globs={'provideUtility': provideUtility,
                                     'provideAdapter': provideAdapter,
+                                    'provideHandler': provideHandler,
                                     'getEvents': getEvents,
                                     'clearEvents': clearEvents,
-                                    'subscribe': ztapi.subscribe,
                                     }),
         doctest.DocFileSuite('groupfolder.txt',
                              setUp=placelesssetup.setUp,



More information about the Checkins mailing list