cubicweb/pyramid/test/__init__.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Tue, 21 Feb 2017 17:41:32 +0100
changeset 11971 6c035cfef04f
parent 11958 950ce7d9f642
child 12088 477a59a45786
permissions -rw-r--r--
[pyramid] Use existing repo in PyramidCWTest We thus do not make use of config_from_cwconfig() and build the configurator instance by hand prior to include 'cubicweb.pyramid'.

import webtest

from pyramid.config import Configurator
from cubicweb.devtools.webtest import CubicWebTestTC


class PyramidCWTest(CubicWebTestTC):
    settings = {}

    @classmethod
    def init_config(cls, config):
        super(PyramidCWTest, cls).init_config(config)
        config.global_set_option('anonymous-user', 'anon')

    def setUp(self):
        # Skip CubicWebTestTC setUp
        super(CubicWebTestTC, self).setUp()
        config = Configurator(settings=self.settings)
        config.registry['cubicweb.repository'] = self.repo
        config.include('cubicweb.pyramid')
        self.includeme(config)
        self.pyr_registry = config.registry
        self.webapp = webtest.TestApp(
            config.make_wsgi_app(),
            extra_environ={'wsgi.url_scheme': 'https'})

    def includeme(self, config):
        pass