Skip to content

Commit

Permalink
Use correct import path now that the BBB stuff is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
philikon committed Feb 28, 2006
0 parents commit 0506d61
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
97 changes: 97 additions & 0 deletions xmlrpc/tests/test_directives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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.
#
##############################################################################
"""Test 'xmlrpc' ZCML Namespace directives.
$Id$
"""
import unittest

from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
from zope.app.component.tests.views import Request, IC, V1
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.security.proxy import ProxyFactory
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest

from zope.app import zapi
from zope.app.publisher import xmlrpc
from zope.interface import implements


request = Request(IXMLRPCRequest)

class Ob(object):
implements(IC)

ob = Ob()

class DirectivesTest(PlacelessSetup, unittest.TestCase):

def testView(self):
self.assertEqual(
zapi.queryMultiAdapter((ob, request), name='test'), None)
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
view = zapi.queryMultiAdapter((ob, request), name='test')
self.assert_(V1 in view.__class__.__bases__)
self.assert_(xmlrpc.MethodPublisher in view.__class__.__bases__)

def testInterfaceProtectedView(self):
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
v = zapi.getMultiAdapter((ob, request), name='test2')
v = ProxyFactory(v)
self.assertEqual(v.index(), 'V1 here')
self.assertRaises(Exception, getattr, v, 'action')

def testAttributeProtectedView(self):
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
v = zapi.getMultiAdapter((ob, request), name='test3')
v = ProxyFactory(v)
self.assertEqual(v.action(), 'done')
self.assertRaises(Exception, getattr, v, 'index')

def testInterfaceAndAttributeProtectedView(self):
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
v = zapi.getMultiAdapter((ob, request), name='test4')
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')

def testDuplicatedInterfaceAndAttributeProtectedView(self):
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
v = zapi.getMultiAdapter((ob, request), name='test5')
self.assertEqual(v.index(), 'V1 here')
self.assertEqual(v.action(), 'done')

def testIncompleteProtectedView(self):
self.assertRaises(ConfigurationError, xmlconfig.file,
"xmlrpc_error.zcml", xmlrpc.tests)

def testNoPermission(self):
self.assertRaises(ConfigurationError, xmlconfig.file,
"xmlrpc_noperm.zcml", xmlrpc.tests)

def test_no_name(self):
xmlconfig.file("xmlrpc.zcml", xmlrpc.tests)
v = zapi.getMultiAdapter((ob, request), name='index')
self.assertEqual(v(), 'V1 here')
v = zapi.getMultiAdapter((ob, request), name='action')
self.assertEqual(v(), 'done')


def test_suite():
return unittest.TestSuite((
unittest.makeSuite(DirectivesTest),
))

if __name__ == '__main__':
unittest.main()
14 changes: 14 additions & 0 deletions xmlrpc/tests/xmlrpc_error.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
i18n_domain="zope">

<include package="zope.app.publisher.xmlrpc" file="meta.zcml"/>

<xmlrpc:view
name="test"
factory="zope.app.component.tests.views.V1"
for="zope.app.component.tests.views.IC"
methods="action index"
permission="zope.Public" />

</configure>

0 comments on commit 0506d61

Please sign in to comment.