[Zope3-checkins] CVS: Products3/z3checkins/tests - test_message.py:1.9

Marius Gedminas mgedmin@codeworks.lt
Fri, 18 Apr 2003 04:39:51 -0400


Update of /cvs-repository/Products3/z3checkins/tests
In directory cvs.zope.org:/tmp/cvs-serv15581/tests

Modified Files:
	test_message.py 
Log Message:
z3checkins: make sure "same as previous" works in the presence of bookmarks.


=== Products3/z3checkins/tests/test_message.py 1.8 => 1.9 ===
--- Products3/z3checkins/tests/test_message.py:1.8	Fri Apr 18 04:30:36 2003
+++ Products3/z3checkins/tests/test_message.py	Fri Apr 18 04:39:50 2003
@@ -406,6 +406,23 @@
 class IUnitTestPresentation(Interface):
     pass
 
+class MessageTestView:
+    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'
+
+class BookmarkTestView:
+    def __init__(self, context, request):
+        self.context = context
+    def __call__(self, template_usage='', same_as_previous=False):
+        return '-\n'
+
 class RequestStub(dict):
 
     _cookies = ()
@@ -646,18 +663,8 @@
         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)
+        provideView(ICheckinMessage, 'html', IUnitTestPresentation,
+                    MessageTestView)
 
         res = view.renderCheckins()
         self.assertEquals(res, 'msg3\nmsg2\nmsg1*\n')
@@ -666,6 +673,25 @@
         view.index.usage = 'sidebar'
         res = view.renderCheckins()
         self.assertEquals(res, 'msg3[sidebar]\nmsg2[sidebar]\nmsg1*[sidebar]\n')
+
+    def test_renderCheckins_with_bookmarks(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 = ''
+        view.bookmarks = lambda: [1]
+        provideView(ICheckinMessage, 'html', IUnitTestPresentation,
+                    MessageTestView)
+        provideView(ICheckinBookmark, 'html', IUnitTestPresentation,
+                    BookmarkTestView)
+
+        res = view.renderCheckins()
+        self.assertEquals(res, 'msg3\nmsg2\n-\nmsg1*\n')
 
 
 def diff(a, b):