[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services/tests - test_bundle.py:1.2.2.1 test_field_widget.py:1.7.16.1 test_rolecontents.py:1.3.16.1 test_service.py:1.2.12.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:17 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/services/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/browser/services/tests
Modified Files:
Tag: cw-mail-branch
test_field_widget.py test_rolecontents.py test_service.py
Added Files:
Tag: cw-mail-branch
test_bundle.py
Log Message:
Synced up with HEAD
=== Added File Zope3/src/zope/app/browser/services/tests/test_bundle.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Unit tests for BundleView class.
XXX Incomplete.
$Id: test_bundle.py,v 1.2.2.1 2003/06/22 14:22:46 gregweb Exp $
"""
# standard library modules
import unittest
# Zope modules
from zope.interface import Interface, implements
from zope.app.interfaces.traversing import IPhysicallyLocatable
from zope.publisher.browser import BrowserView
# Zope test support modules
from zope.app.tests.placelesssetup import PlacelessSetup
# Zope module being tested
from zope.app.browser.services.bundle import BundleView
class SampleClass(object):
implements(IPhysicallyLocatable)
def __init__(self, path="/foo"):
self.path = path
def getPath(self):
return self.path
def items(self):
return []
class TestBundleView(PlacelessSetup, unittest.TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
def test_parseVersion(self):
bv = BundleView(SampleClass(), None)
pv = bv.parseVersion
self.assertEquals(pv("/foo/bar-666"), ["f000000666", "f"])
self.assertEquals(pv("/foo/bar-1.0"),
["f000000001", "f000000000", "f"])
self.assertEquals(pv("foo-bar-2.3.4"),
["f000000002", "f000000003", "f000000004", "f"])
self.assertEquals(pv("bar-5.6.a7"), ["f000000005", "f000000006", "a7"])
self.assertEquals(pv("foo"), None)
self.assertEquals(pv("foo-bar"), None)
self.assertEquals(pv("foo.1.0"), None)
self.assertEquals(pv("foo-1.a1.0"), None)
def test_inOlderVersion(self):
bv = BundleView(SampleClass("/++etc++site/foo-bar-1.0.0"), None)
iov = bv.inOlderVersion
self.failUnless(iov(SampleClass("/++etc++site/foo-bar-0.9/RM/1")))
self.failIf(iov(SampleClass("/++etc++site/bar-foo-0.9/RM/2")))
self.failIf(iov(SampleClass("/++etc++site/foo-bar-1.1/RM/3")))
def test_listServices(self):
bv = BundleView(SampleClass("/++etc++site/foo-bar-1.0.0"), None)
infos = bv.listServices()
self.assertEquals(infos, [])
def test_listRegistrations(self):
bv = BundleView(SampleClass("/++etc++site/foo-bar-1.0.0"), None)
infos = bv.listRegistrations()
self.assertEquals(infos, [])
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBundleView))
return suite
if __name__ == '__main__':
unittest.main()
=== Zope3/src/zope/app/browser/services/tests/test_field_widget.py 1.7 => 1.7.16.1 ===
--- Zope3/src/zope/app/browser/services/tests/test_field_widget.py:1.7 Sun Mar 23 17:35:36 2003
+++ Zope3/src/zope/app/browser/services/tests/test_field_widget.py Sun Jun 22 10:22:46 2003
@@ -19,8 +19,7 @@
from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.traversing import traverse
-from zope.interface import Interface
-from zope.app.services.service import ServiceManager
+from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
class FakeComponentPath:
@@ -43,10 +42,10 @@
class I2(Interface): pass
class C:
- __implements__ = I1
+ implements(I1)
class D:
- __implements__ = I2
+ implements(I2)
instanceOfComponentC = C()
@@ -57,9 +56,7 @@
return ComponentPathWidget(field, request)
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ PlacefulSetup.setUp(self, site=True)
default = traverse(self.rootFolder, '++etc++site/default')
default.setObject('c1', C())
default.setObject('c2', C())
=== Zope3/src/zope/app/browser/services/tests/test_rolecontents.py 1.3 => 1.3.16.1 ===
--- Zope3/src/zope/app/browser/services/tests/test_rolecontents.py:1.3 Thu Mar 13 13:49:03 2003
+++ Zope3/src/zope/app/browser/services/tests/test_rolecontents.py Sun Jun 22 10:22:46 2003
@@ -18,7 +18,7 @@
import unittest
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.app.browser.services.role import Contents
from zope.app.services.role import RoleService
from zope.app.browser.container.tests.test_contents \
@@ -28,12 +28,17 @@
pass
class Dummy:
- __implements__ = IDummy
+ implements(IDummy)
class Test(BaseTestContentsBrowserView, unittest.TestCase):
def _TestView__newContext(self):
- return RoleService()
+ from zope.app.container.sample import SampleContainer
+ from zope.app.content.folder import RootFolder
+ from zope.app.context import ContextWrapper
+ root = RootFolder()
+ container = RoleService()
+ return ContextWrapper(container, root, name='sample')
def _TestView__newView(self, container):
from zope.publisher.browser import TestRequest
=== Zope3/src/zope/app/browser/services/tests/test_service.py 1.2 => 1.2.12.1 ===
--- Zope3/src/zope/app/browser/services/tests/test_service.py:1.2 Wed Apr 30 19:37:57 2003
+++ Zope3/src/zope/app/browser/services/tests/test_service.py Sun Jun 22 10:22:46 2003
@@ -11,13 +11,13 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Unit tests for service adding and configuration views.
+"""Unit tests for service adding and registration views.
$Id$
"""
import unittest
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
from zope.component.view import provideView
from zope.publisher.interfaces.browser import IBrowserPresentation
@@ -27,7 +27,7 @@
pass
class Foo:
- __implements__ = IFoo
+ implements(IFoo)
def __init__(self, url='some_url'):
self.url = url
@@ -43,7 +43,7 @@
return self.context.url
__call__ = __str__
provideView(IFoo, 'absolute_url', IBrowserPresentation, AU)
- provideView(IFoo, 'addConfiguration.html', IBrowserPresentation, AU)
+ provideView(IFoo, 'addRegistration.html', IBrowserPresentation, AU)
context = Foo('foo_url')
request = TestRequest()
@@ -52,7 +52,7 @@
self.assertEquals(view.nextURL(), 'foo_url/@@contents.html')
view.added_object = Foo('bar_url')
- self.assertEquals(view.nextURL(), 'bar_url/@@addConfiguration.html')
+ self.assertEquals(view.nextURL(), 'bar_url/@@addRegistration.html')
# XXX: add tests for other methods and classes