[Zope3-checkins] CVS: Zope3/src/zope/component/tests -
factory.py:1.4 test_providefactory.py:1.6
Sidnei da Silva
sidnei at x3ng.com.br
Tue Aug 5 11:25:50 EDT 2003
Update of /cvs-repository/Zope3/src/zope/component/tests
In directory cvs.zope.org:/tmp/cvs-serv14539/src/zope/component/tests
Modified Files:
factory.py test_providefactory.py
Log Message:
Reasonably big batch of changes. Added methods to query factories by interface. Added tests for them. Registered all fields from zope.schema as factories. Added basic tests for that. Made the contentdirective use a dottedname instead of a class as the id when an id is not provided. Cleanspace Whitening here and there.
=== Zope3/src/zope/component/tests/factory.py 1.3 => 1.4 ===
--- Zope3/src/zope/component/tests/factory.py:1.3 Fri Jun 6 15:29:08 2003
+++ Zope3/src/zope/component/tests/factory.py Tue Aug 5 10:25:16 2003
@@ -22,6 +22,9 @@
"""the dummy interface which class X supposedly implements,
according to the factory"""
+class IFoo(Interface):
+ """an even more dummy interface just for testing """
+
class X:
implements(IX)
def __init__(self, *args, **kwargs):
=== Zope3/src/zope/component/tests/test_providefactory.py 1.5 => 1.6 ===
--- Zope3/src/zope/component/tests/test_providefactory.py:1.5 Thu May 1 15:35:39 2003
+++ Zope3/src/zope/component/tests/test_providefactory.py Tue Aug 5 10:25:16 2003
@@ -20,7 +20,7 @@
from unittest import TestCase, main, makeSuite
from zope.component.tests.placelesssetup import PlacelessSetup
from zope.component.servicenames import Factories
-
+from zope.component.exceptions import ComponentLookupError
class ProvideFactoryTestCase(PlacelessSetup, TestCase):
@@ -32,6 +32,28 @@
thing = createObject(None,"Some.Object")
self.assert_(isinstance(thing, X))
+ def test_getFactoriesFor(self):
+ from zope.component import getService, createObject
+ from zope.component.tests.factory import f, X, IX
+ factories=getService(None, Factories)
+ factories.provideFactory("Some.Object", f)
+ fs = factories.getFactoriesFor(IX)
+ self.assertEqual(fs, [f])
+
+ def test_getFactoriesForUnregistered(self):
+ from zope.component import getService, createObject
+ from zope.component.tests.factory import f, X, IX, IFoo
+ factories=getService(None, Factories)
+ factories.provideFactory("Some.Object", f)
+ self.assertRaises(ComponentLookupError, factories.getFactoriesFor,
+ IFoo)
+
+ def test_queryFactoriesForUnregistered(self):
+ from zope.component import getService, createObject
+ from zope.component.tests.factory import f, X, IX, IFoo
+ factories=getService(None, Factories)
+ factories.provideFactory("Some.Object", f)
+ self.assertEqual(factories.queryFactoriesFor(IFoo, None), None)
def test_suite():
return makeSuite(ProvideFactoryTestCase)
More information about the Zope3-Checkins
mailing list