[Zope3-checkins] CVS: Zope3/src/zope/app/publisher/xmlrpc/tests -
test_directives.py:1.6.2.1
Philipp von Weitershausen
philikon at philikon.de
Wed Aug 6 11:28:32 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/publisher/xmlrpc/tests
In directory cvs.zope.org:/tmp/cvs-serv14946/publisher/xmlrpc/tests
Modified Files:
Tag: zcml-interface-field-branch
test_directives.py
Log Message:
Fix up tests to use the ConfigurationMachine from zope.app.configure which
is service-aware.
=== Zope3/src/zope/app/publisher/xmlrpc/tests/test_directives.py 1.6 => 1.6.2.1 ===
--- Zope3/src/zope/app/publisher/xmlrpc/tests/test_directives.py:1.6 Sun Aug 3 19:47:51 2003
+++ Zope3/src/zope/app/publisher/xmlrpc/tests/test_directives.py Wed Aug 6 10:27:58 2003
@@ -17,21 +17,20 @@
"""
import unittest
+from zope.interface import implements
from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
from zope.component.tests.views import IC, V1
from zope.component import getView, queryView
-from zope.app.tests.placelesssetup import PlacelessSetup
from zope.security.proxy import ProxyFactory
-from cStringIO import StringIO
-
from zope.component.tests.request import Request
-
from zope.publisher.interfaces.xmlrpc import IXMLRPCPresentation
-from zope.app.publisher import xmlrpc
-from zope.interface import implements
+import zope.app.configuration
+import zope.app.component.service
+import zope.app.publisher.xmlrpc.tests
+from zope.app.tests.placelesssetup import PlacelessSetup
request = Request(IXMLRPCPresentation)
@@ -42,57 +41,63 @@
class DirectivesTest(PlacelessSetup, unittest.TestCase):
+ def _config(self):
+ sm = zope.app.component.service.globalServiceManager()
+ context = zope.app.configuration.ConfigurationMachine(sm)
+ xmlconfig.registerCommonDirectives(context)
+ xmlconfig.file('xmlrpc.zcml', package=zope.app.publisher.xmlrpc.tests,
+ context=context)
+ self._context = context
+
def testView(self):
self.assertEqual(queryView(ob, 'test', request), None)
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
self.assertEqual(queryView(ob, 'test', request).__class__, V1)
-
def testInterfaceProtectedView(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'test2', request)
v = ProxyFactory(v)
self.assertEqual(v.index(), 'V1 here')
self.assertRaises(Exception, getattr, v, 'action')
-
def testAttributeProtectedView(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'test3', request)
v = ProxyFactory(v)
self.assertEqual(v.action(), 'done')
self.assertRaises(Exception, getattr, v, 'index')
-
def testInterfaceAndAttributeProtectedView(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'test4', request)
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')
-
def testDuplicatedInterfaceAndAttributeProtectedView(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'test5', request)
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')
-
def testIncompleteProtectedViewNoPermission(self):
+ sm = zope.app.component.service.globalServiceManager()
+ context = zope.app.configuration.ConfigurationMachine(sm)
+ xmlconfig.registerCommonDirectives(context)
self.assertRaises(ConfigurationError, xmlconfig.file,
- "xmlrpc_error.zcml", xmlrpc.tests)
-
+ 'xmlrpc_error.zcml',
+ package=zope.app.publisher.xmlrpc.tests,
+ context=context)
def testMethodViews(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'index2.html', request)
self.assertEqual(v(), 'V1 here')
v = getView(ob, 'action2.html', request)
self.assertEqual(v(), 'done')
-
def testMethodViewsWithName(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
v = getView(ob, 'index3.html', request)
self.assertEqual(v(), 'V1 here')
v = getView(ob, 'action3.html', request)
@@ -101,9 +106,8 @@
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')
-
def testProtectedMethodViews(self):
- context = xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
+ self._config()
# Need to "log someone in" to turn on checks
from zope.security.management import newSecurityManager
newSecurityManager('someuser')
@@ -112,7 +116,6 @@
self.assertRaises(Exception, v)
v = getView(ob, 'action4.html', request)
self.assertEqual(v(), 'done')
-
def test_suite():
return unittest.TestSuite((
More information about the Zope3-Checkins
mailing list