[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/Browser/tests - testNameComponentConfigurableView.py:1.1 testNameConfigurableView.py:NONE
Steve Alexander
steve@cat-box.net
Wed, 18 Dec 2002 15:23:05 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv12654/lib/python/Zope/App/OFS/Services/Browser/tests
Added Files:
testNameComponentConfigurableView.py
Removed Files:
testNameConfigurableView.py
Log Message:
SteveA and Marius G.
We refactored the NamedComponentConfiguration and ComponentConfiguration.
Now, we have NamedConfiguration and NamedComponentConfiguration.
NamedConfigurable is now split into two parts, as appropriate to that
refactoring.
Cleaned up various extraneous imports, and changed various
self --> wrapped_self. (Interestingly, this act revealed one ContextMethod
that did not in fact need to be a ContextMethod.)
=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/tests/testNameComponentConfigurableView.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.
#
##############################################################################
"""Unit test for the generic NameComponentConfigurable view mixin
$Id: testNameComponentConfigurableView.py,v 1.1 2002/12/18 20:23:04 stevea Exp $
"""
from unittest import TestCase, TestSuite, main, makeSuite
from Interface import Interface
from Zope.Publisher.Browser.BrowserRequest import TestRequest
from Zope.App.tests.PlacelessSetup import PlacelessSetup
from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
from Zope.ComponentArchitecture.GlobalViewService import provideView
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.OFS.Services.Browser.NameComponentConfigurableView \
import NameComponentConfigurableView
from Zope.App.Traversing.ITraversable import ITraversable
class SM:
def __init__(self, **data):
self._data = data
def listConfigurationNames(self):
return self._data.keys()
def queryConfigurations(self, name):
return self._data[name]
class I(Interface): pass
class Registry:
__implements__ = I
def __init__(self, active):
self._active = active
def active(self):
return self._active
class ITestConfiguration(Interface): pass
class Configuration:
__implements__ = ITestConfiguration, ITraversable
def __init__(self, path):
self.componentPath = path
def traverse(self, name, parameters, original_name, furtherPath):
return self
class V(BrowserView):
_update = 0
def setPrefix(self, p):
self._prefix = p
def update(self):
self._update += 1
class AU(BrowserView):
def __str__(self):
return "/" + self.context.componentPath
class Test(PlacelessSetup, TestCase):
def test_update(self):
provideView(I, 'ChangeConfigurations', IBrowserPresentation, V)
provideView(ITestConfiguration, 'absolute_url', IBrowserPresentation,
AU)
r1 = Registry(None)
r2 = Registry(Configuration('1'))
r3 = Registry(Configuration('1'))
sm = SM(test1=r1, test2=r2, test3=r3)
services = NameComponentConfigurableView(sm, TestRequest()).update()
self.assertEqual(len(services), 3)
self.assertEqual(services[0]['name'], 'test1')
self.assertEqual(services[0]['active'], False)
self.assertEqual(services[0]['inactive'], True)
self.assertEqual(services[0]['view'].context, r1)
self.assertEqual(services[0]['view']._prefix, "test1")
self.assertEqual(services[0]['view']._update, 1)
self.assertEqual(services[0]['url'], None)
self.assertEqual(services[1]['name'], 'test2')
self.assertEqual(services[1]['active'], True)
self.assertEqual(services[1]['inactive'], False)
self.assertEqual(services[1]['view'].context, r2)
self.assertEqual(services[1]['view']._prefix, "test2")
self.assertEqual(services[1]['view']._update, 1)
self.assertEqual(services[1]['url'], '/1')
self.assertEqual(services[2]['name'], 'test3')
self.assertEqual(services[2]['active'], True)
self.assertEqual(services[2]['inactive'], False)
self.assertEqual(services[2]['view'].context, r3)
self.assertEqual(services[2]['view']._prefix, "test3")
self.assertEqual(services[2]['view']._update, 1)
self.assertEqual(services[2]['url'], '/1')
def test_suite():
return TestSuite((
makeSuite(Test),
))
if __name__=='__main__':
main(defaultTest='test_suite')
=== Removed File Zope3/lib/python/Zope/App/OFS/Services/Browser/tests/testNameConfigurableView.py ===