Registers a repoze.bfg ‘view permission’ object under the name name. The view permission return a result denoted by the result argument. If result is True, a repoze.bfg.security.Allowed object is returned; else a repoze.bfg.security.Denied object is returned. To gain more control, if you pass in a non-None viewpermission, this view permission object will be used instead of an automatically generated view permission (and result is not used). This method is useful when dealing with code that wants to call, e.g. repoze.bfg.view.view_execution_permitted. Note that view permissions are not checked unless a security policy is in effect (see registerSecurityPolicy).
This function was deprecated in repoze.bfg 1.1.
Register a new route using a path (e.g. :pagename), a name (e.g. ‘home’), and an optional root factory. This is useful for testing code that calls e.g. route_url.
Note
This API was added in repoze.bfg version 1.1.
Register a new routes mapper using the provided root_factory as the root factory it wraps. If root_factory is None, use a default root factory implementation.
Use of this function is beneficial when you want to register an empty routes mapper with a custom root_factory.
Note that repoze.bfg.testing.registerRoute also registers a route mapper if one is not already registered, thus it is not necessary to call this function before calling repoze.bfg.testing.registerRoute. However, if repoze.bfg.registerRoutesMapper is called before repoze.bfg.testing.registerRoute, the routes mapper registered by repoze.bfg.testing.registerRoutesMapper will be used as the mapper in which the route is registered during repoze.bfg.testing.registerRoute.
Note
This API was added in repoze.bfg version 1.1.
Register one or more ‘setting’ key/value pairs. A setting is a single key/value pair in the dictionary-ish object returned from the API repoze.bfg.settings.get_settings().
You may pass a dictionary:
registerSettings({'external_uri':'http://example.com'})
Or a set of key/value pairs:
registerSettings(external_uri='http://example.com')
Use of this function is required when you need to test code that calls the repoze.bfg.settings.get_settings() API and uses return values from it.
Note
This API is new as of repoze.bfg 1.1.
Set up a fresh BFG testing registry. Use in the setUp method of unit tests that use the register* methods in the testing module (e.g. if your unit test uses repoze.bfg.testing.registerDummySecurityPolicy). If you use the register* functions without calling setUp, unit tests will not be isolated with respect to registrations they perform. Additionally, the global component registry will be used, which may have a different API than is expected by BFG itself.
Note
This feature is new as of repoze.bfg 1.1.
Tear down a previously set up (via repoze.bfg.testing.setUp) testing registry. Use in the tearDown method of unit tests that use the register* methods in the testing module (e.g. if your unit test uses repoze.bfg.testing.registerDummySecurityPolicy). Using tearDown is effectively optional if you call setUp at the beginning of every test which requires registry isolation.
Note
This feature is new as of repoze.bfg 1.1.
Given a ZCML filename as name and a Python package as package which the filename should be relative to, load the ZCML into the current ZCML registry.
Note
This feature is new as of repoze.bfg 1.1.
A dummy repoze.bfg model object. The value of name to the constructor will be used as the __name__ attribute of the model. the value of parent will be used as the __parent__ attribute of the model.
A dummy request object (imitates a WebOb Request object).
The params, environ, headers, path, and cookies arguments correspond to their WebOb equivalents.
The post argument, if passed, populates the request’s POST attribute, but not params, in order to allow testing that the app accepts data for a given view only from POST requests. This argument also sets self.method to “POST”.
Extra keyword arguments are assigned as attributes of the request itself.
An instance of this class is returned from registerTemplateRenderer. It has a helper function (assert_) that makes it possible to make an assertion which compares data passed to the renderer by the view function against expected key/value pairs.