[Zope3-checkins] CVS: Zope3/src/zope/app/renderer/tests - test_renderers.py:1.1 test_vocabulary.py:1.3 renderer.zcml:NONE test_directives.py:NONE test_plaintext.py:NONE test_rest.py:NONE test_sourcetype.py:NONE test_stx.py:NONE

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 2 09:25:16 EST 2004


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

Modified Files:
	test_vocabulary.py 
Added Files:
	test_renderers.py 
Removed Files:
	renderer.zcml test_directives.py test_plaintext.py 
	test_rest.py test_sourcetype.py test_stx.py 
Log Message:


Reimplemented source types to use factories and the factory service instead
implementing its own service. The vocabulary was also updated accordingly.




=== Added File Zope3/src/zope/app/renderer/tests/test_renderers.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.
#
##############################################################################
"""Renderer Tests

$Id: test_renderers.py,v 1.1 2004/03/02 14:24:45 srichter Exp $
"""
import unittest
from zope.testing.doctestunit import DocTestSuite

def test_suite():
    return unittest.TestSuite((
        DocTestSuite('zope.app.renderer.plaintext'),
        DocTestSuite('zope.app.renderer.rest'),
        DocTestSuite('zope.app.renderer.stx'),
        ))

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')


=== Zope3/src/zope/app/renderer/tests/test_vocabulary.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/renderer/tests/test_vocabulary.py:1.2	Thu Nov 27 08:59:24 2003
+++ Zope3/src/zope/app/renderer/tests/test_vocabulary.py	Tue Mar  2 09:24:45 2004
@@ -17,54 +17,54 @@
 """
 import unittest
 
-from zope.app.interfaces.renderer import IGlobalSourceTypeService
-from zope.app.renderer.sourcetype import SourceTypes
+from zope.app import zapi
+from zope.app.renderer import SourceFactory
+from zope.app.renderer.interfaces import ISource
 from zope.app.renderer.vocabulary import SourceTypeTerm, SourceTypeVocabulary
-from zope.component.service import defineService, serviceManager
+from zope.component.factory import FactoryInfo
 from zope.component.tests.placelesssetup import PlacelessSetup
-from zope.interface import Interface, implements
 from zope.schema.interfaces import \
      ITokenizedTerm, IVocabulary, IVocabularyTokenized
 
 
+class IFoo(ISource):
+    """Source marker interface"""
 
-class IFoo(Interface):
-    pass
+FooFactory = SourceFactory(IFoo)
 
-class Foo:
-    implements(IFoo)
+class IFoo2(ISource):
+    """Source marker interface"""
 
-class IFoo2(Interface):
-    pass
+Foo2Factory = SourceFactory(IFoo2)
 
-class Foo2:
-    implements(IFoo2)
 
 
 class SourceTypeTermTest(unittest.TestCase):
 
     def setUp(self):
-        self.term = SourceTypeTerm('Foo')
+        self.term = SourceTypeTerm('zope.Foo', FactoryInfo('Foo', 'Foo Source'))
 
     def test_Interface(self):
         self.failUnless(ITokenizedTerm.isImplementedBy(self.term))
 
     def test_token(self):
-        self.assertEqual(self.term.token, 'Foo')
+        self.assertEqual(self.term.token, 'zope.Foo')
 
     def test_value(self):
-        self.assertEqual(self.term.value, 'Foo')
+        self.assertEqual(self.term.value, 'zope.Foo')
 
 
 class SourceTypeVocabularyTest(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
         super(SourceTypeVocabularyTest, self).setUp()
-        defineService("SourceTypeRegistry", IGlobalSourceTypeService)
-        serviceManager.provideService("SourceTypeRegistry", SourceTypes)
-        SourceTypes._clear()
-        SourceTypes.provide('Foo', IFoo, Foo)
-        SourceTypes.provide('Foo 2', IFoo2, Foo2)
+        
+        factories = zapi.getService(None, 'Factories')
+        factories.provideFactory('zope.source.Foo', FooFactory,
+                                 FactoryInfo('Foo', 'Foo Source'))
+        factories.provideFactory('zope.source.Foo2', Foo2Factory,
+                                 FactoryInfo('Foo2', 'Foo2 Source'))
+
         self.vocab = SourceTypeVocabulary(None)
 
     def test_Interface(self):
@@ -72,19 +72,16 @@
         self.failUnless(IVocabularyTokenized.isImplementedBy(self.vocab))
 
     def test_contains(self):
-        self.assertEqual(self.vocab.__contains__('Foo'), True)
-        self.assertEqual(self.vocab.__contains__('Foo 3'), False)
+        self.assertEqual(self.vocab.__contains__('zope.source.Foo'), True)
+        self.assertEqual(self.vocab.__contains__('zope.source.Foo3'), False)
 
     def test_iter(self):
-        vocab = self.vocab
-        self.assertEqual('Foo' in map(lambda x: x.value, vocab.__iter__()),
-                         True)
-        self.assertEqual('Foo 3' in map(lambda x: x.value, vocab.__iter__()),
-                         False)
-        self.assertEqual('Foo' in map(lambda x: x.value, iter(vocab)),
-                         True)
-        self.assertEqual('Foo 3' in map(lambda x: x.value, iter(vocab)),
-                         False)
+        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)
 
     def test_len(self):
         self.assertEqual(self.vocab.__len__(), 2)
@@ -94,13 +91,13 @@
         self.assertEqual(self.vocab.getQuery(), None)
 
     def test_getTerm(self):
-        self.assertEqual(self.vocab.getTerm('Foo').value, 'Foo')
-        self.assertRaises(KeyError, self.vocab.getTerm, ('Foo 3',))
+        self.assertEqual(self.vocab.getTerm('zope.source.Foo').title, 'Foo')
+        self.assertRaises(KeyError, self.vocab.getTerm, ('zope.source.Foo3',))
 
     def test_getTermByToken(self):
         vocab = self.vocab
-        self.assertEqual(vocab.getTermByToken('Foo').value, 'Foo')
-        self.assertRaises(KeyError, vocab.getTermByToken, ('Foo 3',))
+        self.assertEqual(vocab.getTermByToken('zope.source.Foo').title, 'Foo')
+        self.assertRaises(KeyError, vocab.getTermByToken, ('zope.source.Foo3',))
 
 
 def test_suite():

=== Removed File Zope3/src/zope/app/renderer/tests/renderer.zcml ===

=== Removed File Zope3/src/zope/app/renderer/tests/test_directives.py ===

=== Removed File Zope3/src/zope/app/renderer/tests/test_plaintext.py ===

=== Removed File Zope3/src/zope/app/renderer/tests/test_rest.py ===

=== Removed File Zope3/src/zope/app/renderer/tests/test_sourcetype.py ===

=== Removed File Zope3/src/zope/app/renderer/tests/test_stx.py ===




More information about the Zope3-Checkins mailing list