Product configuration and testing

Status: IsImplementedProposal, IsImplemented
Author: FredDrake?

The product configuration functions in zope.app.appsetup.product do not lend themselves to allowing a test to modify a portion of the configuration from within a larger test fixture and then restore the modified portions of the environment.

Note: This proposal represents a band-aid to deal with some of the heinous testing pain engendered by the existing API; it isn't a next-generation API. Something based on the component architecture would be much nicer to work with most (if not all) of the time. Just how such a system should interact with the existing product configuration API isn't completely clear.

There's been no time to address the lack of a roadmap to something better, but the lack of a reasonable API to deal with "product" configuration has become an increasingly significant problem for application development. The API documented here has been implemented and released as part of zope.app.appsetup 3.6.0.

This interface for testing support of product configuration would provide sufficient flexibility for most tests:

class IProductConfigurationTestingAPI(interface.Interface):
    """API to manage product configuration in a test environment."""

    def setProductConfiguration(name, mapping):
        """Set the product configuration for `name` to `mapping`.

        If `mapping` is ``None``, any existing configuration for `name` will
        be removed.  Existing configuration for `name` will not be required.

        """

    def saveConfiguration():
        """Return an opaque object representing all product configuration.

        The value is opaque, and should only be saved and later passed to
        ``restoreConfiguration``.

        The value may not be suitable for persistence.

        """

    def restoreConfiguration(state):
        """Restore configuration based on state from ``saveConfiguration``.

        Results are undefined if `state` was not provided by
        ``saveConfiguration``.

        """

This interface would be added to zope.app.appsetup.interfaces and would be directly provided by the zope.app.appsetup.product module.

Note that this proposal does not address the general painfulness of the "product configuration" API; something more reasonable to start with would be a better move. (Avoiding the global variable used in the existing implementation would be a step in the right direction.)



( 96 subscribers )