[Checkins] SVN: Products.PluggableAuthService/trunk/ Fix creation of PropertiesUpdated event.
Tres Seaver
tseaver at palladion.com
Thu Jun 9 11:38:03 EDT 2011
Log message for revision 121904:
Fix creation of PropertiesUpdated event.
Add test coverage for event classes, and some PEP 8 cleanups.
Closes Launchpad #795086.
Changed:
U Products.PluggableAuthService/trunk/CHANGES.txt
U Products.PluggableAuthService/trunk/Products/PluggableAuthService/events.py
A Products.PluggableAuthService/trunk/Products/PluggableAuthService/tests/test_events.py
-=-
Modified: Products.PluggableAuthService/trunk/CHANGES.txt
===================================================================
--- Products.PluggableAuthService/trunk/CHANGES.txt 2011-06-09 14:50:56 UTC (rev 121903)
+++ Products.PluggableAuthService/trunk/CHANGES.txt 2011-06-09 15:38:03 UTC (rev 121904)
@@ -4,7 +4,7 @@
1.7.6 (unreleased)
------------------
-- TBD
+- Launchpad #795086: fixed creation of PropertiesUpdated event.
1.7.5 (2011-05-30)
------------------
Modified: Products.PluggableAuthService/trunk/Products/PluggableAuthService/events.py
===================================================================
--- Products.PluggableAuthService/trunk/Products/PluggableAuthService/events.py 2011-06-09 14:50:56 UTC (rev 121903)
+++ Products.PluggableAuthService/trunk/Products/PluggableAuthService/events.py 2011-06-09 15:38:03 UTC (rev 121904)
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation and Contributors
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this
+# distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
from Acquisition import aq_parent
from zope.component import adapter
from zope.component import subscribers
@@ -2,11 +15,21 @@
from zope.interface import implements
-from Products.PluggableAuthService.interfaces.events import *
+
from Products.PluggableAuthService.interfaces.authservice import IBasicUser
+from Products.PluggableAuthService.interfaces.events \
+ import ICredentialsUpdatedEvent
+from Products.PluggableAuthService.interfaces.events import IPASEvent
+from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalCreatedEvent
+from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalDeletedEvent
+from Products.PluggableAuthService.interfaces.events \
+ import IPropertiesUpdatedEvent
+
class PASEvent(object):
implements(IPASEvent)
def __init__(self, principal):
- self.principal=principal
- self.object=principal
+ self.principal = principal
+ self.object = principal
@@ -26,15 +49,15 @@
def __init__(self, principal, password):
super(CredentialsUpdated, self).__init__(principal)
- self.password=password
+ self.password = password
class PropertiesUpdated(PASEvent):
implements(IPropertiesUpdatedEvent)
def __init__(self, principal, properties):
- super(CredentialsUpdated, self).__init__(principal)
- self.properties=properties
+ super(PropertiesUpdated, self).__init__(principal)
+ self.properties = properties
@adapter(IBasicUser, ICredentialsUpdatedEvent)
Added: Products.PluggableAuthService/trunk/Products/PluggableAuthService/tests/test_events.py
===================================================================
--- Products.PluggableAuthService/trunk/Products/PluggableAuthService/tests/test_events.py (rev 0)
+++ Products.PluggableAuthService/trunk/Products/PluggableAuthService/tests/test_events.py 2011-06-09 15:38:03 UTC (rev 121904)
@@ -0,0 +1,141 @@
+##############################################################################
+#
+# Copyright (c) 2011 Zope Foundation and Contributors
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this
+# distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import unittest
+
+
+class ConformsToIPASEvent:
+
+ def test_class_conforms_to_IPASEvent(self):
+ from zope.interface.verify import verifyClass
+ from Products.PluggableAuthService.interfaces.events import IPASEvent
+ verifyClass(IPASEvent, self._getTargetClass())
+
+ def test_instance_conforms_to_IPASEvent(self):
+ from zope.interface.verify import verifyObject
+ from Products.PluggableAuthService.interfaces.events import IPASEvent
+ verifyObject(IPASEvent, self._makeOne())
+
+
+class PASEventTests(unittest.TestCase, ConformsToIPASEvent):
+
+ def _getTargetClass(self):
+ from Products.PluggableAuthService.events import PASEvent
+ return PASEvent
+
+ def _makeOne(self, principal=None):
+ if principal is None:
+ principal = DummyPrincipal()
+ return self._getTargetClass()(principal)
+
+
+class PrincipalCreatedTests(unittest.TestCase, ConformsToIPASEvent):
+
+ def _getTargetClass(self):
+ from Products.PluggableAuthService.events import PrincipalCreated
+ return PrincipalCreated
+
+ def _makeOne(self, principal=None):
+ if principal is None:
+ principal = DummyPrincipal()
+ return self._getTargetClass()(principal)
+
+ def test_class_conforms_to_IPrincipalCreatedEvent(self):
+ from zope.interface.verify import verifyClass
+ from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalCreatedEvent
+ verifyClass(IPrincipalCreatedEvent, self._getTargetClass())
+
+ def test_instance_conforms_to_IPrincipalCreatedEvent(self):
+ from zope.interface.verify import verifyObject
+ from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalCreatedEvent
+ verifyObject(IPrincipalCreatedEvent, self._makeOne())
+
+
+class PrincipalDeletedTests(unittest.TestCase, ConformsToIPASEvent):
+
+ def _getTargetClass(self):
+ from Products.PluggableAuthService.events import PrincipalDeleted
+ return PrincipalDeleted
+
+ def _makeOne(self, principal=None):
+ if principal is None:
+ principal = DummyPrincipal()
+ return self._getTargetClass()(principal)
+
+ def test_class_conforms_to_IPrincipalDeletedEvent(self):
+ from zope.interface.verify import verifyClass
+ from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalDeletedEvent
+ verifyClass(IPrincipalDeletedEvent, self._getTargetClass())
+
+ def test_instance_conforms_to_IPrincipalDeletedEvent(self):
+ from zope.interface.verify import verifyObject
+ from Products.PluggableAuthService.interfaces.events \
+ import IPrincipalDeletedEvent
+ verifyObject(IPrincipalDeletedEvent, self._makeOne())
+
+
+class CredentialsUpdatedTests(unittest.TestCase, ConformsToIPASEvent):
+
+ def _getTargetClass(self):
+ from Products.PluggableAuthService.events import CredentialsUpdated
+ return CredentialsUpdated
+
+ def _makeOne(self, principal=None, password='password'):
+ if principal is None:
+ principal = DummyPrincipal()
+ return self._getTargetClass()(principal, password)
+
+ def test_class_conforms_to_ICredentialsUpdatedEvent(self):
+ from zope.interface.verify import verifyClass
+ from Products.PluggableAuthService.interfaces.events \
+ import ICredentialsUpdatedEvent
+ verifyClass(ICredentialsUpdatedEvent, self._getTargetClass())
+
+ def test_instance_conforms_to_ICredentialsUpdatedEvent(self):
+ from zope.interface.verify import verifyObject
+ from Products.PluggableAuthService.interfaces.events \
+ import ICredentialsUpdatedEvent
+ verifyObject(ICredentialsUpdatedEvent, self._makeOne())
+
+
+class PropertiesUpdatedTests(unittest.TestCase, ConformsToIPASEvent):
+
+ def _getTargetClass(self):
+ from Products.PluggableAuthService.events import PropertiesUpdated
+ return PropertiesUpdated
+
+ def _makeOne(self, principal=None, properties=None):
+ if principal is None:
+ principal = DummyPrincipal()
+ if properties is None:
+ properties = {}
+ return self._getTargetClass()(principal, properties)
+
+ def test_class_conforms_to_IPropertiesUpdatedEvent(self):
+ from zope.interface.verify import verifyClass
+ from Products.PluggableAuthService.interfaces.events \
+ import IPropertiesUpdatedEvent
+ verifyClass(IPropertiesUpdatedEvent, self._getTargetClass())
+
+ def test_instance_conforms_to_IPropertiesUpdatedEvent(self):
+ from zope.interface.verify import verifyObject
+ from Products.PluggableAuthService.interfaces.events \
+ import IPropertiesUpdatedEvent
+ verifyObject(IPropertiesUpdatedEvent, self._makeOne())
+
+
+class DummyPrincipal(object):
+ pass
More information about the checkins
mailing list