[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/ApplicationControl/tests - testAbsoluteURL.py:1.1.2.1
Christian Theune
ct@gocept.com
Wed, 27 Nov 2002 01:10:58 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/ApplicationControl/tests
In directory cvs.zope.org:/tmp/cvs-serv32601
Added Files:
Tag: ctheune-fix_appcontrol-branch
testAbsoluteURL.py
Log Message:
Added test case for the AbsoluteURL view
=== Added File Zope3/lib/python/Zope/App/OFS/ApplicationControl/tests/testAbsoluteURL.py ===
##############################################################################
#
# 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.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.
#
##############################################################################
"""Test the AbsoluteURL view
Revision information:
$Id: testAbsoluteURL.py,v 1.1.2.1 2002/11/27 06:10:57 ctheune Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from Interface import Interface
from Zope.App.tests.PlacelessSetup import PlacelessSetup
from Zope.ComponentArchitecture import getService, getView
from Zope.I18n.IUserPreferredCharsets import IUserPreferredCharsets
from Zope.Publisher.HTTP.tests.TestRequest import TestRequest
from Zope.Publisher.HTTP.HTTPRequest import IHTTPRequest
from Zope.Publisher.HTTP.HTTPCharsets import HTTPCharsets
from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
from Zope.Proxy.ContextWrapper import ContextWrapper
from Zope.App.OFS.ApplicationControl.ApplicationControl import ApplicationControl
class IRoot(Interface): pass
class Root:
__implements__ = IRoot
class TrivialContent(object):
"""Trivial content object, used because instances of object are rocks."""
class Test(PlacelessSetup, TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
from Zope.App.OFS.ApplicationControl.ApplicationControl \
import ApplicationControlAbsoluteURL
provideView=getService(None,"Views").provideView
provideView(None, 'absolute_url', IBrowserPresentation,
[ApplicationControlAbsoluteURL])
provideAdapter = getService(None, "Adapters").provideAdapter
provideAdapter(IHTTPRequest, IUserPreferredCharsets, HTTPCharsets)
def testApplicationControlView(self):
request = TestRequest()
request.setViewType(IBrowserPresentation)
view = getView(ApplicationControl(), 'absolute_url', request)
self.assertEqual(str(view), '++etc++ApplicationController')
def testApplicationControlBreadcrumbs(self):
request = TestRequest()
request.setViewType(IBrowserPresentation)
content = ApplicationControl()
view = getView(content, 'absolute_url', request)
self.assertEqual(str(view),
'http://foobar.com/++etc++ApplicationController')
breadcrumbs = view.breadcrumbs()
self.assertEqual(breadcrumbs,
({'name': '', 'url': 'http://foobar.com'},
{'name': '++etc++ApplicationController',
'url': 'http://foobar.com/' \
'++etc++ApplicationController'},
))
def testContextWSideEffectsInFront(self):
request = TestRequest()
request.setViewType(IBrowserPresentation)
root = Root()
content = ContextWrapper(root, root, name='.',
side_effect_name="++skin++ZopeTop")
content = ContextWrapper(ApplicationControl(), content)
view = getView(content, 'absolute_url', request)
self.assertEqual(str(view),
'http://foobar.com/++skin++ZopeTop/++etc++ApplicationController')
breadcrumbs = view.breadcrumbs()
self.assertEqual(breadcrumbs,
({'name': '', 'url': 'http://foobar.com/++skin++ZopeTop'},
{'name': '++etc++ApplicationControl',
'url': 'http://foobar.com/++skin++ZopeTop/' \
'++etc++ApplicationController'},
))
def test_suite():
return makeSuite(Test)
if __name__=='__main__':
main(defaultTest='test_suite')