[Zope3-checkins] CVS: Products3/z3checkins/tests -
test_message.py:1.16
Gintautas Miliauskas
gintas at pov.lt
Tue Jan 13 12:08:56 EST 2004
Update of /cvs-repository/Products3/z3checkins/tests
In directory cvs.zope.org:/tmp/cvs-serv24299/tests
Modified Files:
test_message.py
Log Message:
- Updated a number of places that had been broken by geddons.
- Properties are contained in Fields rather than in metadata.
- Made use of preconditions and other nice features.
- Uncommented a few assertions that seemed to apply.
=== Products3/z3checkins/tests/test_message.py 1.15 => 1.16 ===
--- Products3/z3checkins/tests/test_message.py:1.15 Wed Oct 15 15:42:54 2003
+++ Products3/z3checkins/tests/test_message.py Tue Jan 13 12:08:55 2004
@@ -13,18 +13,14 @@
from StringIO import StringIO
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.component import getService, servicenames
from zope.interface import Interface, implements
from zope.interface.verify import verifyObject
from zope.context import getWrapperContext, getWrapperData
-from zope.app.context import ContextWrapper
+from zope.context import Wrapper
-from zopeproducts.z3checkins.interfaces import IMessage
-from zopeproducts.z3checkins.interfaces import ICheckinMessage
-from zopeproducts.z3checkins.interfaces import IBookmark
-from zopeproducts.z3checkins.interfaces import IMessageParser
-from zopeproducts.z3checkins.interfaces import IMessageArchive
+from zopeproducts.z3checkins.interfaces import IMessage, IMessageContained, \
+ ICheckinMessage, IBookmark, IMessageParser, IMessageArchive
class TestFixedTimezone(unittest.TestCase):
@@ -367,7 +363,7 @@
from zopeproducts.z3checkins.message import FixedTimezone
parser = CheckinMessageParser()
msg = parser.parse(StringIO(self.svn_msg))
- #self.assert_(ICheckinMessage.isImplementedBy(msg))
+ self.assert_(ICheckinMessage.isImplementedBy(msg))
self.assertEquals(msg.message_id, "<20030908101551.6F900C32F at mail.pov.lt>")
self.assertEquals(msg.author, "Albertas Agejevas <alga at pov.lt>")
self.assertEquals(msg.author_name, "Albertas Agejevas")
@@ -385,7 +381,7 @@
from zopeproducts.z3checkins.message import FixedTimezone
parser = CheckinMessageParser()
msg = parser.parse(StringIO(self.svn_msg_with_split_subject))
- #self.assert_(ICheckinMessage.isImplementedBy(msg))
+ self.assert_(ICheckinMessage.isImplementedBy(msg))
self.assertEquals(msg.message_id, "<20030908101551.6F900C32F at mail.pov.lt>")
self.assertEquals(msg.author, "Albertas Agejevas <alga at pov.lt>")
self.assertEquals(msg.author_name, "Albertas Agejevas")
@@ -401,7 +397,7 @@
class MessageStub:
- implements(ICheckinMessage)
+ implements(ICheckinMessage, IMessageContained)
def __init__(self, data=None, date=None, body=None, log_message='',
message_id="<message at id>"):
@@ -522,6 +518,9 @@
class IUnitTestPresentation(Interface):
pass
+class IRequest(Interface):
+ pass
+
class MessageTestView:
def __init__(self, context, request):
self.context = context
@@ -541,6 +540,8 @@
class RequestStub(dict):
+ implements(IRequest)
+
_cookies = ()
def __init__(self, **kw):
@@ -564,7 +565,7 @@
from zopeproducts.z3checkins.message import MessageContainerAdapter
getService(None, 'Adapters').provideAdapter(None,
IMessageArchive,
- MessageContainerAdapter)
+ [MessageContainerAdapter])
def test_checkins(self):
from zopeproducts.z3checkins.message import ContainerView
@@ -779,8 +780,9 @@
view.request = RequestStub()
view.index = view
view.index.usage = ''
- provideView(ICheckinMessage, 'html', IUnitTestPresentation,
- MessageTestView)
+ getService(None, servicenames.Presentation).provideView(
+ ICheckinMessage, 'html', IRequest,
+ [MessageTestView])
res = view.renderCheckins()
self.assertEquals(res, 'msg3\nmsg2\nmsg1*\n')
@@ -801,10 +803,12 @@
view.index = view
view.index.usage = ''
view.bookmarks = lambda: [1]
- provideView(ICheckinMessage, 'html', IUnitTestPresentation,
- MessageTestView)
- provideView(IBookmark, 'html', IUnitTestPresentation,
- BookmarkTestView)
+ getService(None, servicenames.Presentation).provideView(
+ ICheckinMessage, 'html', IRequest,
+ [MessageTestView])
+ getService(None, servicenames.Presentation).provideView(
+ IBookmark, 'html', IRequest,
+ [BookmarkTestView])
res = view.renderCheckins()
self.assertEquals(res, 'msg3\nmsg2\n-\nmsg1*\n')
@@ -843,7 +847,7 @@
from zopeproducts.z3checkins.message import MessageContainerAdapter
getService(None, 'Adapters').provideAdapter(None,
IMessageArchive,
- MessageContainerAdapter)
+ [MessageContainerAdapter])
def test_body_strange(self):
from zopeproducts.z3checkins.message import CheckinMessageView
@@ -1110,7 +1114,7 @@
def test_navigation_empty_archive(self):
from zopeproducts.z3checkins.message import CheckinMessageView
view = CheckinMessageView()
- view.context = ContextWrapper(MessageStub(), {'1': 2})
+ view.context = Wrapper(MessageStub(), {'1': 2})
self.assertEquals(view.first(), None)
self.assertEquals(view.last(), None)
self.assertEquals(view.next(), None)
@@ -1124,21 +1128,21 @@
m4 = MessageStub(date=4, message_id='4')
folder = {'1': 2, '3': 'abc', '4': m1, '5': m2, '6': m3, '7': m4}
view = CheckinMessageView()
- view.context = ContextWrapper(m3, folder)
+ view.context = Wrapper(m3, folder)
self.assertEquals(view.first(), m1)
self.assertEquals(view.last(), m4)
self.assertEquals(view.next(), m4)
self.assertEquals(view.previous(), m2)
view = CheckinMessageView()
- view.context = ContextWrapper(m1, folder)
+ view.context = Wrapper(m1, folder)
self.assertEquals(view.first(), m1)
self.assertEquals(view.last(), m4)
self.assertEquals(view.next(), m2)
self.assertEquals(view.previous(), None)
view = CheckinMessageView()
- view.context = ContextWrapper(m4, folder)
+ view.context = Wrapper(m4, folder)
self.assertEquals(view.first(), m1)
self.assertEquals(view.last(), m4)
self.assertEquals(view.next(), None)
More information about the Zope3-Checkins
mailing list