[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/Caching/tests - testCacheName.py:1.1

Jim Fulton jim@zope.com
Mon, 11 Nov 2002 15:57:21 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/Caching/tests
In directory cvs.zope.org:/tmp/cvs-serv20886/tests

Added Files:
	testCacheName.py 
Log Message:

Changed the cacheName field to implement allowed_values, rather than
items and to use bound context rather than context wrappers.

Changed the cachable editing view to use a standard editing widget and
the new widget setup code in Zope.App.Forms.Utility.

Got rid of an unused import of FormView.



=== Added File Zope3/lib/python/Zope/App/Caching/tests/testCacheName.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 CacheName field

In particular, test the proper getting of cache names in allowed_values.

$Id: testCacheName.py,v 1.1 2002/11/11 20:57:20 jim Exp $
"""

from unittest import TestCase, TestSuite, main, makeSuite
from Zope.Proxy.ContextWrapper import ContextWrapper

from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \
     import PlacefulSetup
from Zope.App.OFS.Services.ServiceManager.tests.TestServiceManager \
     import TestServiceManager

from Zope.App.Caching.ICacheable import CacheName

class CachingServiceStub(object):

    def getAvailableCaches(self):
        return 'foo', 'bar', 'baz'

    
class Test(PlacefulSetup, TestCase):

    def setUp(self):
        PlacefulSetup.setUp(self)
        self.buildFolders()
        sm = TestServiceManager()
        self.rootFolder.setServiceManager(sm)
        sm.Caching = CachingServiceStub()        

    def test(self):
        field = CacheName().bind(self.rootFolder)
        allowed = list(field.allowed_values)
        allowed.sort()
        self.assertEqual(allowed, ['', 'bar', 'baz', 'foo'])

    
def test_suite():
    return TestSuite((
        makeSuite(Test),
        ))

if __name__=='__main__':
    main(defaultTest='test_suite')