[Checkins] SVN: zc.comment/trunk/src/zc/comment/ Fixed all outstanding unit and functional tests and finally the package

Stephan Richter srichter at cosmos.phy.tufts.edu
Mon Apr 21 20:01:43 EDT 2008


Log message for revision 85578:
  Fixed all outstanding unit and functional tests and finally the package 
  is coming together. I think I am getting ready to release.
  

Changed:
  U   zc.comment/trunk/src/zc/comment/README.txt
  U   zc.comment/trunk/src/zc/comment/browser/README.txt
  U   zc.comment/trunk/src/zc/comment/browser/ftesting.zcml
  U   zc.comment/trunk/src/zc/comment/browser/tests.py
  U   zc.comment/trunk/src/zc/comment/browser/views.py
  U   zc.comment/trunk/src/zc/comment/comment.py
  U   zc.comment/trunk/src/zc/comment/configure.zcml
  U   zc.comment/trunk/src/zc/comment/interfaces.py
  D   zc.comment/trunk/src/zc/comment/ntests.py
  D   zc.comment/trunk/src/zc/comment/test.zcml

-=-
Modified: zc.comment/trunk/src/zc/comment/README.txt
===================================================================
--- zc.comment/trunk/src/zc/comment/README.txt	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/README.txt	2008-04-22 00:01:42 UTC (rev 85578)
@@ -162,8 +162,14 @@
     >>> comments.add(42)
     Traceback (most recent call last):
     ...
-    ValueError: comment body must be unicode
+    WrongType: (42, <type 'unicode'>)
 
+If you like, you can always clear all comments:
+
+    >>> comments.clear()
+    >>> len(comments)
+    0
+
 And of course some cleanup:
 
     >>> zope.security.management.endInteraction()

Modified: zc.comment/trunk/src/zc/comment/browser/README.txt
===================================================================
--- zc.comment/trunk/src/zc/comment/browser/README.txt	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/browser/README.txt	2008-04-22 00:01:42 UTC (rev 85578)
@@ -1,3 +1,4 @@
+=============
 Commenting UI
 =============
 
@@ -18,6 +19,7 @@
 
 Let's visit the object and click on the comments tab:
 
+    >>> browser.handleErrors = False
     >>> browser.getLink('number').click()
     >>> browser.getLink('[[zc.comment][Comments]]').click()
 

Modified: zc.comment/trunk/src/zc/comment/browser/ftesting.zcml
===================================================================
--- zc.comment/trunk/src/zc/comment/browser/ftesting.zcml	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/browser/ftesting.zcml	2008-04-22 00:01:42 UTC (rev 85578)
@@ -1,4 +1,7 @@
-<configure xmlns="http://namespaces.zope.org/zope">
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:browser="http://namespaces.zope.org/browser"
+   i18n_domain="zc.comment">
 
   <include package="zope.app.zcmlfiles" />
   <include package="zope.app.zcmlfiles" file="ftesting.zcml" />
@@ -6,4 +9,36 @@
   <include package="zc.comment" />
   <include package="zc.comment.browser" />
 
+  <include package="zc.resourcelibrary" file="meta.zcml" />
+  <include package="zc.resourcelibrary" />
+  <include package="zope.formlib" />
+  <include package="zc.comment" />
+  <include package="zc.table" />
+
+  <utility component="zc.comment.browser.tests.formatterFactory" />
+  <adapter factory="zc.comment.browser.tests.requestToTZInfo" />
+
+  <class class="zc.comment.browser.tests.MyContent">
+    <implements
+        interface="zope.annotation.interfaces.IAttributeAnnotatable"
+        />
+    <implements interface="zc.comment.interfaces.ICommentable" />
+  </class>
+
+  <browser:addMenuItem
+      class="zc.comment.browser.tests.MyContent"
+      title="Content"
+      permission="zope.ManageContent"
+      />
+
+  <unauthenticatedPrincipal id="zope.anybody" title="Unauthenticated User" />
+
+  <!-- Load a "default" i18n domain for debugging purposes
+       production sites shouldn't do this -->
+  <include package="zope.app.i18n.tests" />
+
+  <securityPolicy
+      component="zope.security.simplepolicies.PermissiveSecurityPolicy" />
+
+
 </configure>

Modified: zc.comment/trunk/src/zc/comment/browser/tests.py
===================================================================
--- zc.comment/trunk/src/zc/comment/browser/tests.py	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/browser/tests.py	2008-04-22 00:01:42 UTC (rev 85578)
@@ -17,14 +17,20 @@
 """
 __docformat__ = "reStructuredText"
 import os
+import persistent
+import pytz
+import re
 import unittest
 import zope.component
 import zope.interface
+import zope.interface.common.idatetime
 import zope.app.form.interfaces
 import zope.app.testing.functional
 import zope.publisher.browser
+import zope.testing.renormalizing
+import zc.table
 from zope.app.form.browser.tests import test_browserwidget
-from zope.app.testing.functional import ZCMLLayer
+from zope.app.testing.functional import FunctionalDocFileSuite, ZCMLLayer
 
 import zc.comment.interfaces
 import zc.comment.browser.widget
@@ -48,6 +54,20 @@
            u"Bar &lt; &amp; &gt;")
 
 
+class MyContent(persistent.Persistent):
+    x = 0
+
+ at zope.component.adapter(zope.publisher.interfaces.IRequest)
+ at zope.interface.implementer(zope.interface.common.idatetime.ITZInfo)
+def requestToTZInfo(request):
+    return pytz.timezone('US/Eastern')
+
+def formatterFactory(*args, **kw):
+    return zc.table.table.FormFullFormatter(*args, **kw)
+zope.interface.directlyProvides(formatterFactory,
+                                zc.table.interfaces.IFormatterFactory)
+
+
 class WidgetConfigurationTestCase(unittest.TestCase):
     """Check that configure.zcml sets up the widgets as expected."""
 
@@ -151,14 +171,24 @@
 
 
 def test_suite():
-    suite = unittest.TestSuite()
+    suites = []
     for cls in (DisplayWidgetTestCase,
                 InputWidgetTestCase,
                 ):
-        suite.addTest(unittest.makeSuite(cls))
+        suites.append(unittest.makeSuite(cls))
 
     widgetConfig = unittest.makeSuite(WidgetConfigurationTestCase)
     widgetConfig.layer = CommentsLayer
-    suite.addTest(widgetConfig)
+    suites.append(widgetConfig)
 
-    return suite
+    checker = zope.testing.renormalizing.RENormalizing([
+        (re.compile(r'\d\d\d\d \d\d? \d\d?\s+\d\d:\d\d:\d\d( [+-]\d+)?'),
+         'YYYY MM DD  HH:MM:SS'),
+        ])
+
+    readme = FunctionalDocFileSuite(
+        os.path.join('README.txt'), checker=checker)
+    readme.layer = CommentsLayer
+    suites.append(readme)
+
+    return unittest.TestSuite(suites)

Modified: zc.comment/trunk/src/zc/comment/browser/views.py
===================================================================
--- zc.comment/trunk/src/zc/comment/browser/views.py	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/browser/views.py	2008-04-22 00:01:42 UTC (rev 85578)
@@ -44,14 +44,14 @@
     principals = zapi.principals()
     return [principals.getPrincipal(pid) for pid in context.principal_ids]
 
-def principalsFormatter(value, context, formatter): 
+def principalsFormatter(value, context, formatter):
     return ', '.join([v.title for v in value])
 
 columns = [
     SortableColumn(
         _('comment_column-date','Date'), lambda c, f: c.date, dateFormatter),
     SortableColumn(
-        _('comment_column-principals', 'Principals'), principalsGetter, 
+        _('comment_column-principals', 'Principals'), principalsGetter,
         principalsFormatter),
     zc.table.column.GetterColumn( # XXX escape?
         _('comment_column-comment', 'Comment'), lambda c, f: c.body)

Modified: zc.comment/trunk/src/zc/comment/comment.py
===================================================================
--- zc.comment/trunk/src/zc/comment/comment.py	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/comment.py	2008-04-22 00:01:42 UTC (rev 85578)
@@ -27,16 +27,18 @@
 import zope.location
 import zope.security.management
 import zope.publisher.interfaces
+from zope.schema.fieldproperty import FieldProperty
 from zope.annotation import factory
 
 from zc.comment import interfaces
 
-class Comment(persistent.Persistent):
+class Comment(zope.location.Location, persistent.Persistent):
     zope.interface.implements(interfaces.IComment)
+    body = FieldProperty(interfaces.IComment['body'])
+    date = FieldProperty(interfaces.IComment['date'])
+    principal_ids = FieldProperty(interfaces.IComment['principal_ids'])
 
     def __init__(self, body):
-        if not isinstance(body, unicode):
-            raise ValueError("comment body must be unicode")
         self.body = body
         self.date = datetime.datetime.now(pytz.utc)
         interaction = zope.security.management.getInteraction()
@@ -56,10 +58,11 @@
     insert = append = remove = reverse = sort = extend = pop
 
     def add(self, body):
-        super(Comments, self).append(Comment(body))
-        zope.event.notify(interfaces.CommentAdded(self.__parent__, body))
+        comment = Comment(body)
+        super(Comments, self).append(comment)
+        zope.event.notify(interfaces.CommentAdded(self.__parent__, comment))
 
-    def clear(self): # XXX no test
+    def clear(self):
         persistent.list.PersistentList.__init__(self)
 
     def __repr__(self):

Modified: zc.comment/trunk/src/zc/comment/configure.zcml
===================================================================
--- zc.comment/trunk/src/zc/comment/configure.zcml	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/configure.zcml	2008-04-22 00:01:42 UTC (rev 85578)
@@ -14,7 +14,6 @@
   <adapter
       factory=".comment.CommentsFactory"
       trusted="True"
-       permission="zope.View"
       />
 
 </configure>

Modified: zc.comment/trunk/src/zc/comment/interfaces.py
===================================================================
--- zc.comment/trunk/src/zc/comment/interfaces.py	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/interfaces.py	2008-04-22 00:01:42 UTC (rev 85578)
@@ -70,8 +70,10 @@
     """Somone added a comment to some content
     """
 
-    comment = zope.schema.Text(
-        title=u"The comment entered")
+    comment = zope.schema.Object(
+        title=u'Comment',
+        description=u'The comment object that has been created.',
+        schema=IComment)
 
 
 class CommentAdded(zope.lifecycleevent.ObjectModifiedEvent):

Deleted: zc.comment/trunk/src/zc/comment/ntests.py
===================================================================
--- zc.comment/trunk/src/zc/comment/ntests.py	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/ntests.py	2008-04-22 00:01:42 UTC (rev 85578)
@@ -1,61 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Visible Source
-# License, Version 1.0 (ZVSL).  A copy of the ZVSL 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.
-#
-##############################################################################
-"""
-
-$Id: ntests.py 4280 2005-12-01 21:39:17Z benji $
-"""
-
-import persistent
-import pytz
-import re
-import unittest
-from zope.testing import doctest
-from zope import component, interface
-import zope.interface.common.idatetime
-import zope.testing.renormalizing
-import zc.table
-
-from zope.app.testing.functional import defineLayer
-
-
-class MyContent(persistent.Persistent):
-    x = 0
-
- at zope.component.adapter(zope.publisher.interfaces.IRequest)
- at zope.interface.implementer(zope.interface.common.idatetime.ITZInfo)
-def requestToTZInfo(request):
-    return pytz.timezone('US/Eastern')
-
-def formatterFactory(*args, **kw):
-    return zc.table.table.FormFullFormatter(*args, **kw)
-interface.directlyProvides(formatterFactory,
-                           zc.table.interfaces.IFormatterFactory)
-
-defineLayer('CommentLayer')
-
-def test_suite():
-    checker = zope.testing.renormalizing.RENormalizing([
-        (re.compile(r'\d\d\d\d \d\d? \d\d?\s+\d\d:\d\d:\d\d( [+-]\d+)?'),
-         'YYYY MM DD  HH:MM:SS'),
-        ])
-    suite = doctest.DocFileSuite('browser/comments.txt', checker=checker,
-                                 optionflags=doctest.NORMALIZE_WHITESPACE |
-                                             doctest.ELLIPSIS)
-    suite.layer = CommentLayer
-    return suite
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
-

Deleted: zc.comment/trunk/src/zc/comment/test.zcml
===================================================================
--- zc.comment/trunk/src/zc/comment/test.zcml	2008-04-21 23:53:51 UTC (rev 85577)
+++ zc.comment/trunk/src/zc/comment/test.zcml	2008-04-22 00:01:42 UTC (rev 85578)
@@ -1,60 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
-           xmlns:browser="http://namespaces.zope.org/browser"
-           xmlns:zcml="http://namespaces.zope.org/zcml"
-           package="zc.comment"
-           i18n_domain="zc.comment"
-           >
-
-  <include
-      zcml:condition="installed zope.app.zcmlfiles"
-      package="zope.app.zcmlfiles"
-      />
-  <include
-      zcml:condition="not-installed zope.app.zcmlfiles"
-      package="zope.app"
-      />
-
-<!-- uncomment to run interactively and use the test recorder
-<include package="zope.app.server" />
-
-<configure package="zope.browsertestrecorder">
-<browser:resourceDirectory
-      name="recorder"
-      directory="html"
-      />
-</configure>
-
--->
-
-<securityPolicy
-      component="zope.security.simplepolicies.PermissiveSecurityPolicy" />
-
-<include package="zc.resourcelibrary" file="meta.zcml" />
-<include package="zc.resourcelibrary" />
-<include package="zope.formlib" />
-<include package="zc.comment" />
-<include package="zc.table" />
-
-<utility component=".ntests.formatterFactory" />
-<adapter factory=".ntests.requestToTZInfo" />
-
-<class class=".ntests.MyContent">
-  <implements
-      interface="zope.annotation.interfaces.IAttributeAnnotatable"
-      />
-  <implements interface="zc.comment.interfaces.ICommentable" />
-</class>
-
-<browser:addMenuItem
-    class=".ntests.MyContent"
-    title="Content"
-    permission="zope.ManageContent"
-    />
-
-<unauthenticatedPrincipal id="zope.anybody" title="Unauthenticated User" />
-
-<!-- Load a "default" i18n domain for debugging purposes
-     production sites shouldn't do this -->
-<include package="zope.app.i18n.tests" />
-
-</configure>



More information about the Checkins mailing list