[Zope3-checkins] CVS: Zope3/src/zope/app/renderer/tests - test_vocabulary.py:1.6

Gary Poster gary at zope.com
Thu May 6 12:14:19 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/renderer/tests
In directory cvs.zope.org:/tmp/cvs-serv9758/src/zope/app/renderer/tests

Modified Files:
	test_vocabulary.py 
Log Message:
Convert the field collection behavior as described in 
http://mail.zope.org/pipermail/zope3-dev/2004-May/010797.html

The Sequence field is removed.  As I spoke with Stephan, it may be acceptable to add the Sequence field back in if it actually means something.  Sequence did mean it was iterable but container access API was not described.  It should be described.  IPythonSequence might describe this API.  A Sequence widget should require specification of the factory.

Set now specifies a sets.Set.

IChoiceSequence was removed.




=== Zope3/src/zope/app/renderer/tests/test_vocabulary.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/renderer/tests/test_vocabulary.py:1.5	Tue Mar  9 07:39:09 2004
+++ Zope3/src/zope/app/renderer/tests/test_vocabulary.py	Thu May  6 12:13:48 2004
@@ -21,7 +21,7 @@
 from zope.app.tests import ztapi
 from zope.app.renderer import SourceFactory
 from zope.app.renderer.interfaces import ISource
-from zope.app.renderer.vocabulary import SourceTypeTerm, SourceTypeVocabulary
+from zope.app.renderer.vocabulary import SourceTypeVocabulary
 from zope.component.interfaces import IFactory
 from zope.component.tests.placelesssetup import PlacelessSetup
 from zope.schema.interfaces import \
@@ -38,31 +38,15 @@
 
 Foo2Factory = SourceFactory(IFoo2, 'Foo2', 'Foo2 Source')
 
-
-
-class SourceTypeTermTest(unittest.TestCase):
-
-    def setUp(self):
-        self.term = SourceTypeTerm('zope.Foo', FooFactory)
-
-    def test_Interface(self):
-        self.failUnless(ITokenizedTerm.providedBy(self.term))
-
-    def test_token(self):
-        self.assertEqual(self.term.token, 'zope.Foo')
-
-    def test_value(self):
-        self.assertEqual(self.term.value, 'zope.Foo')
-
-
+# XXX the vocabulary uses SimpleVocabulary now, so these tests are a bit 
+# redundant.  Leaving them in as confirmation that the replacement function 
+# works identically to the old custom vocabulary.
 class SourceTypeVocabularyTest(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         super(SourceTypeVocabularyTest, self).setUp()
-        
         ztapi.provideUtility(IFactory, FooFactory, 'zope.source.Foo')
         ztapi.provideUtility(IFactory, Foo2Factory, 'zope.source.Foo2')
-
         self.vocab = SourceTypeVocabulary(None)
 
     def test_Interface(self):
@@ -70,19 +54,16 @@
         self.failUnless(IVocabularyTokenized.providedBy(self.vocab))
 
     def test_contains(self):
-        self.assertEqual(self.vocab.__contains__('zope.source.Foo'), True)
-        self.assertEqual(self.vocab.__contains__('zope.source.Foo3'), False)
+        self.failUnless('zope.source.Foo' in self.vocab)
+        self.failIf('zope.source.Foo3' in self.vocab)
 
     def test_iter(self):
-        self.assertEqual(
-            'zope.source.Foo' in [term.value for term in iter(self.vocab)],
-            True)
-        self.assertEqual(
-            'zope.source.Foo3' in [term.value for term in iter(self.vocab)],
-            False)
+        self.failUnless(
+            'zope.source.Foo' in [term.value for term in self.vocab])
+        self.failIf(
+            'zope.source.Foo3' in [term.value for term in iter(self.vocab)])
 
     def test_len(self):
-        self.assertEqual(self.vocab.__len__(), 2)
         self.assertEqual(len(self.vocab), 2)
 
     def test_getQuery(self):
@@ -90,17 +71,17 @@
 
     def test_getTerm(self):
         self.assertEqual(self.vocab.getTerm('zope.source.Foo').title, 'Foo')
-        self.assertRaises(KeyError, self.vocab.getTerm, ('zope.source.Foo3',))
+        self.assertRaises(
+            LookupError, self.vocab.getTerm, ('zope.source.Foo3',))
 
     def test_getTermByToken(self):
         vocab = self.vocab
         self.assertEqual(vocab.getTermByToken('zope.source.Foo').title, 'Foo')
-        self.assertRaises(KeyError, vocab.getTermByToken, ('zope.source.Foo3',))
-
+        self.assertRaises(
+            LookupError, vocab.getTermByToken, ('zope.source.Foo3',))
 
 def test_suite():
     return unittest.TestSuite((
-        unittest.makeSuite(SourceTypeTermTest),
         unittest.makeSuite(SourceTypeVocabularyTest),
         ))
 




More information about the Zope3-Checkins mailing list