[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - configurationregistry.py:1.1.2.1 iconfigurable.py:1.1.2.1 servicemanager.py:1.1.2.1 placefulsetup.py:1.1.2.5 test_adapter.py:1.1.2.4 test_configurations.py:1.1.2.4 test_configurationstatusproperty.py:1.1.2.3 test_view.py:1.1.2.4 testingconfigurationregistry.py:NONE testingiconfigurable.py:NONE testingservicemanager.py:NONE

Sidnei da Silva sidnei@x3ng.com.br
Tue, 24 Dec 2002 10:21:56 -0500


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

Modified Files:
      Tag: NameGeddon-branch
	placefulsetup.py test_adapter.py test_configurations.py 
	test_configurationstatusproperty.py test_view.py 
Added Files:
      Tag: NameGeddon-branch
	configurationregistry.py iconfigurable.py servicemanager.py 
Removed Files:
      Tag: NameGeddon-branch
	testingconfigurationregistry.py testingiconfigurable.py 
	testingservicemanager.py 
Log Message:
Remove testing prefix from some modules to make the testrunner happy.

=== Added File Zope3/src/zope/app/services/tests/configurationregistry.py ===
##############################################################################
#
# Copyright (c) 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.
# 
##############################################################################

__metaclass__ = type

class TestingConfiguration:
    def __init__(self, id):
        self.id = id

    def __eq__(self, other):
        return self.id == getattr(other, 'id', 0)
    
class TestingConfigurationRegistry:

    class_ = TestingConfiguration

    def __init__(self, *args):
        self._data = args

    def register(self, configuration):
        cid = configuration.id

        if self._data:
            if cid in self._data:
                return # already registered
        else:
            # Nothing registered. Need to stick None in front so that nothing
            # is active.
            self._data = (None, )

        self._data += (cid, )

    def unregister(self, configuration):
        cid = configuration.id

        data = self._data
        if data:
            if data[0] == cid:
                # It's active, we need to switch in None
                self._data = (None, ) + data[1:]
            else:
                self._data = tuple([item for item in data if item != cid])

    def registered(self, configuration):
        cid = configuration.id
        return cid in self._data

    def activate(self, configuration):
        cid = configuration.id
        if self._data[0] == cid:
            return # already active

        if self._data[0] is None:
            # Remove leading None marker
            self._data = self._data[1:]

        self._data = (cid, ) + tuple(
            [item for item in self._data if item != cid]
            )

    def deactivate(self, configuration):
        cid = configuration.id
        if self._data[0] != cid:
            return # already inactive

        # Just stick None on the front
        self._data = (None, ) + self._data

    def active(self):
        if self._data:
            return self.class_(self._data[0])
                
        return None

    def __nonzero__(self):
        return bool(self._data)

    def info(self):
        result = [{'id': path,
                   'active': False,
                   'configuration': self.class_(path),
                   }
                  for path in self._data
                  ]

        if result:
            if result[0]['configuration'] is None:
                del result[0]
            else:
                result[0]['active'] = True
        
        return result


=== Added File Zope3/src/zope/app/services/tests/iconfigurable.py ===
##############################################################################
#
# Copyright (c) 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.
# 
##############################################################################
"""XXX short summary goes here.

XXX longer description goes here.

$Id: iconfigurable.py,v 1.1.2.1 2002/12/24 15:21:53 sidnei Exp $
"""
from zope.app.interfaces.services.configuration import IConfigurable
from zope.interface.verify import verifyObject
from zope.proxy.context import getWrapperContainer

class TestingIConfigurable:
    """Base class for testing implementors of IConfigurable

    Subclasses must implement:

      - createTestingConfigurable()
        that returns a new configurable object with no configurations.

        This configuration object must be in the context of something
        that is not None.

      - createTestingConfiguration()
        that returns a configuration object.

    """

    def _assertInContext(self, ob, parent):
        """Assert that we have the proper context

        The container of ob must be the parent, and the parent must
        have some context.

        """
        self.assertEqual(getWrapperContainer(ob), parent)
        self.failIf(getWrapperContainer(getWrapperContainer(ob)) is None)

    def test_implements_IConfigurable(self):
        verifyObject(IConfigurable, self.createTestingConfigurable())

    def test_queryConfigurationsFor_no_config(self):
        configurable = self.createTestingConfigurable()
        configuration = self.createTestingConfiguration()
        self.failIf(configurable.queryConfigurationsFor(configuration))

        self.assertEqual(
            configurable.queryConfigurationsFor(configuration, 42),
            42)

    def test_createConfigurationsFor(self):
        configurable = self.createTestingConfigurable()
        configuration = self.createTestingConfiguration()
        registry = configurable.createConfigurationsFor(configuration)

        self.assertEqual(getWrapperContainer(registry), configurable)

        # If we call it again, we should get the same object
        self.assertEqual(configurable.createConfigurationsFor(configuration),
                         registry)

        self._assertInContext(registry, configurable)

        return registry

    def test_queryConfigurationsFor(self):
        configurable = self.createTestingConfigurable()
        configuration = self.createTestingConfiguration()

        cregistry = configurable.createConfigurationsFor(configuration)


        registry = configurable.queryConfigurationsFor(configuration)
        self.assertEqual(registry, cregistry)
        self._assertInContext(registry, configurable)

        registry = configurable.queryConfigurationsFor(configuration, 42)
        self.assertEqual(registry, cregistry)
        self._assertInContext(registry, configurable)


=== Added File Zope3/src/zope/app/services/tests/servicemanager.py ===
##############################################################################
#
# Copyright (c) 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.
# 
##############################################################################
"""
$Id: servicemanager.py,v 1.1.2.1 2002/12/24 15:21:53 sidnei Exp $
"""

__metaclass__ = type

from zope.component.interfaces import IServiceService
from zope.app.component.nextservice \
     import getNextService, getNextServiceManager
from zope.proxy.context import ContextWrapper
from zope.app.interfaces.services.service import IBindingAware
from zope.proxy.context import ContextMethod

class TestingServiceManager:
    """Simple placeful service manager used for writing tests
    """
    __implements__ =  IServiceService

    def getServiceDefinitions(self):
        "See IServiceService"
        return getNextServiceManager(self).getServiceDefinitions()

    def getInterfaceFor(self, name):
        "See IServiceService"
        return getNextServiceManager(self).getInterfaceFor(name)

    def getService(self, name):
        "See IServiceService"
        if hasattr(self, name):
            return ContextWrapper(getattr(self, name), self, name=name)
        return getNextServiceManager(self).getService(name)

    getService = ContextMethod(getService)

    def queryService(self, name, default=None):
        "See IServiceService"
        if hasattr(self, name):
            return ContextWrapper(getattr(self, name), self, name=name)
        return getNextServiceManager(self).queryService(name, default)

    queryService = ContextMethod(queryService)

    def bindService(self, name, ob):
        setattr(self, name, ob)
        if IBindingAware.isImplementedBy(ob):
            ob.bound(name)

    bindService = ContextMethod(bindService)

    def unbindService(self, name):
        ob = getattr(self, name)
        if IBindingAware.isImplementedBy(ob):
            ob.unbound(name)
        delattr(self, name, ob)

    unbindService = ContextMethod(unbindService)


__doc__ = TestingServiceManager.__doc__ + __doc__



=== Zope3/src/zope/app/services/tests/placefulsetup.py 1.1.2.4 => 1.1.2.5 ===
--- Zope3/src/zope/app/services/tests/placefulsetup.py:1.1.2.4	Tue Dec 24 01:09:52 2002
+++ Zope3/src/zope/app/services/tests/placefulsetup.py	Tue Dec 24 10:21:53 2002
@@ -133,7 +133,7 @@
     def createServiceManager(self, folder = None):
         if folder is None:
             folder = self.rootFolder
-        from zope.app.services.tests.testingservicemanager \
+        from zope.app.services.tests.servicemanager \
              import TestingServiceManager
 
         folder.setServiceManager(TestingServiceManager())


=== Zope3/src/zope/app/services/tests/test_adapter.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/services/tests/test_adapter.py:1.1.2.3	Tue Dec 24 07:51:18 2002
+++ Zope3/src/zope/app/services/tests/test_adapter.py	Tue Dec 24 10:21:53 2002
@@ -17,7 +17,7 @@
 """
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.services.tests.testingiconfigurable import TestingIConfigurable
+from zope.app.services.tests.iconfigurable import TestingIConfigurable
 from zope.app.services.adapter import AdapterService
 from zope.interface import Interface
 from zope.proxy.context import ContextWrapper


=== Zope3/src/zope/app/services/tests/test_configurations.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/services/tests/test_configurations.py:1.1.2.3	Tue Dec 24 07:51:18 2002
+++ Zope3/src/zope/app/services/tests/test_configurations.py	Tue Dec 24 10:21:53 2002
@@ -26,7 +26,7 @@
 from zope.app.services.configuration import NamedComponentConfiguration
 from zope.app.services.tests.placefulsetup \
         import PlacefulSetup
-from zope.app.services.tests.testingservicemanager \
+from zope.app.services.tests.servicemanager \
         import TestingServiceManager
 from zope.proxy.context import ContextWrapper
 from zope.app.interfaces.dependable import IDependable


=== Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py:1.1.2.2	Mon Dec 23 18:52:36 2002
+++ Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py	Tue Dec 24 10:21:53 2002
@@ -23,7 +23,7 @@
 from zope.app.services.tests.placefulsetup \
      import PlacefulSetup
 from zope.app.services.role import RoleService
-from zope.app.services.tests.testingconfigurationregistry \
+from zope.app.services.tests.configurationregistry \
      import TestingConfigurationRegistry, TestingConfiguration
 from zope.app.services.configuration import ConfigurationStatusProperty
 from zope.app.interfaces.services.configuration \


=== Zope3/src/zope/app/services/tests/test_view.py 1.1.2.3 => 1.1.2.4 ===
--- Zope3/src/zope/app/services/tests/test_view.py:1.1.2.3	Tue Dec 24 07:51:18 2002
+++ Zope3/src/zope/app/services/tests/test_view.py	Tue Dec 24 10:21:53 2002
@@ -17,7 +17,7 @@
 """
 
 from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.services.tests.testingiconfigurable import TestingIConfigurable
+from zope.app.services.tests.iconfigurable import TestingIConfigurable
 from zope.app.services.view import ViewService
 from zope.interface import Interface
 from zope.proxy.context import ContextWrapper

=== Removed File Zope3/src/zope/app/services/tests/testingconfigurationregistry.py ===

=== Removed File Zope3/src/zope/app/services/tests/testingiconfigurable.py ===

=== Removed File Zope3/src/zope/app/services/tests/testingservicemanager.py ===