[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/tests - __init__.py:1.1.2.1 testAbsoluteURL.py:1.1.2.1
Jim Fulton
jim@zope.com
Tue, 9 Apr 2002 12:00:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/tests
In directory cvs.zope.org:/tmp/cvs-serv2326/lib/python/Zope/App/ZopePublication/AbsoluteURL/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testAbsoluteURL.py
Log Message:
added AbsoluteURL view
=== Added File Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/tests/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/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/04/09 16:00:21 jim Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
#############################################################################
# If your tests change any global registries, then uncomment the
# following import and include CleanUp as a base class of your
# test. It provides a setUp and tearDown that clear global data that
# has registered with the test cleanup framework. Don't use this
# tests outside the Zope package.
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
#############################################################################
from Zope.ComponentArchitecture import getRequestView, provideView
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.Publisher.HTTP.tests.TestRequest import TestRequest
from Zope.ContextWrapper import Wrapper
from Interface import Interface
class IRoot(Interface): pass
class Root:
__implements__ = IRoot
class Test(CleanUp, TestCase):
def setUp(self):
from Zope.App.ZopePublication.AbsoluteURL.AbsoluteURL \
import AbsoluteURL, SiteAbsoluteURL
provideView(None, 'url', IBrowserPublisher, AbsoluteURL)
provideView(IRoot, 'url', IBrowserPublisher, SiteAbsoluteURL)
def testNoContext(self):
request = TestRequest()
request.setViewType(IBrowserPublisher)
view = getRequestView(Root(), 'url', request)
self.assertEqual(str(view), 'http://foobar.com')
def testBasicContext(self):
request = TestRequest()
request.setViewType(IBrowserPublisher)
content = Wrapper(None, Root(), name='a')
content = Wrapper(None, content, name='b')
content = Wrapper(None, content, name='c')
view = getRequestView(content, 'url', request)
self.assertEqual(str(view), 'http://foobar.com/a/b/c')
def test_suite():
return TestSuite((
makeSuite(Test),
))
if __name__=='__main__':
main(defaultTest='test_suite')