[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_useconfiguration.py:1.1.2.1

Tim Peters tim.one@comcast.net
Mon, 24 Feb 2003 15:32:59 -0500


Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv31957/src/zope/app/services/tests

Added Files:
      Tag: use-config-branch
	test_useconfiguration.py 
Log Message:
New interface IUseConfiguration and new adapter UseConfiguration, for
a project that will become clearer later.


=== Added File Zope3/src/zope/app/services/tests/test_useconfiguration.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""
$Id: test_useconfiguration.py,v 1.1.2.1 2003/02/24 20:32:59 tim_one Exp $
"""

from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.services.configuration import UseConfiguration
from zope.app.interfaces.annotation import IAnnotations
from zope.app.tests.placelesssetup import PlacelessSetup

class C(dict):
    __implements__ = IAnnotations

class TestUseConfiguration(PlacelessSetup, TestCase):

    def testVerifyInterface(self):
        from zope.interface.verify import verifyObject
        from zope.app.interfaces.services.configuration import IUseConfiguration
        obj = UseConfiguration(C())
        verifyObject(IUseConfiguration, obj)

    def test(self):
        obj = UseConfiguration(C())
        self.failIf(obj.usages())
        obj.addUsage('/a/b')
        obj.addUsage('/c/d')
        obj.addUsage('/c/e')
        locs = list(obj.usages())
        locs.sort()
        self.assertEqual(locs, ['/a/b', '/c/d', '/c/e'])
        obj.removeUsage('/c/d')
        locs = list(obj.usages())
        locs.sort()
        self.assertEqual(locs, ['/a/b', '/c/e'])

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

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