[Zope3-checkins] CVS: Products3/z3checkins/tests - test_message.py:1.8
Marius Gedminas
mgedmin@codeworks.lt
Fri, 18 Apr 2003 04:30:36 -0400
Update of /cvs-repository/Products3/z3checkins/tests
In directory cvs.zope.org:/tmp/cvs-serv13826/tests
Modified Files:
test_message.py
Log Message:
z3checkins:
- Detect several checkins with the same checkin comment and display "Same as
previous" instead of repeating the comment for all of them except for the
first one.
- Moved floating icons inside <a>
- Added a TODO item for displaying times in the user's timezone
=== Products3/z3checkins/tests/test_message.py 1.7 => 1.8 ===
--- Products3/z3checkins/tests/test_message.py:1.7 Fri Apr 18 02:57:48 2003
+++ Products3/z3checkins/tests/test_message.py Fri Apr 18 04:30:36 2003
@@ -12,6 +12,8 @@
from datetime import datetime, timedelta
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component import getService
+from zope.component.view import provideView
+from zope.interface import Interface
from zope.interface.verify import verifyObject
from zope.proxy.context import getWrapperContext, getWrapperData
from zope.proxy.context import ContextWrapper
@@ -285,11 +287,12 @@
__implements__ = ICheckinMessage
- def __init__(self, data=None, date=None, body=None,
+ def __init__(self, data=None, date=None, body=None, log_message='',
message_id="<message@id>"):
self.data = data
self.date = date
self.body = body
+ self.log_message = log_message
self.message_id = message_id
@@ -400,6 +403,9 @@
self.assertEquals(view.context.added.data, "Ipsum suum")
+class IUnitTestPresentation(Interface):
+ pass
+
class RequestStub(dict):
_cookies = ()
@@ -412,6 +418,12 @@
def setCookie(self, name, value, **kw):
self._cookies += (name, value, kw)
+ def getPresentationType(self):
+ return IUnitTestPresentation
+
+ def getPresentationSkin(self):
+ return ''
+
class TestContainerView(PlacelessSetup, unittest.TestCase):
def setUp(self):
@@ -623,6 +635,37 @@
'2003-01-04T21:33:04-05:00 '
'2003-01-06T22:33:44+03:00',
{'max_age': 31536000}))
+
+ def test_renderCheckins(self):
+ from zopeproducts.z3checkins.message import ContainerView
+ view = ContainerView()
+ view.context = {'x': 123, 'y': object(),
+ 'z': MessageStub(date=1, log_message='xxx'),
+ 'a': MessageStub(date=2, log_message='xxx'),
+ 'c': MessageStub(date=3, log_message='yyy')}
+ view.request = RequestStub()
+ view.index = view
+ view.index.usage = ''
+
+ class V:
+ def __init__(self, context, request):
+ self.context = context
+ def __call__(self, template_usage='', same_as_previous=False):
+ result = 'msg%d' % self.context.date
+ if same_as_previous:
+ result += '*'
+ if template_usage:
+ result += '[%s]' % template_usage
+ return result + '\n'
+ provideView(ICheckinMessage, 'html', IUnitTestPresentation, V)
+
+ res = view.renderCheckins()
+ self.assertEquals(res, 'msg3\nmsg2\nmsg1*\n')
+ res = view.renderCheckins(start=1, size=1)
+ self.assertEquals(res, 'msg2\n')
+ view.index.usage = 'sidebar'
+ res = view.renderCheckins()
+ self.assertEquals(res, 'msg3[sidebar]\nmsg2[sidebar]\nmsg1*[sidebar]\n')
def diff(a, b):