cubicweb/pyramid/test/__init__.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 10 Feb 2017 16:33:16 +0100
changeset 11958 950ce7d9f642
parent 11913 4516c3956d46
child 11971 6c035cfef04f
permissions -rw-r--r--
[pyramid] Rename make_cubicweb_application function as config_from_cwconfig And update its docstring. This function does not actually "make a cubicweb application", it just builds a pyramid.config.Configurator instance from a CubicWeb config object.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     1
import webtest
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     2
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     3
from cubicweb.devtools.webtest import CubicWebTestTC
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     4
11958
950ce7d9f642 [pyramid] Rename make_cubicweb_application function as config_from_cwconfig
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11913
diff changeset
     5
from cubicweb.pyramid import config_from_cwconfig
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     6
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     7
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     8
class PyramidCWTest(CubicWebTestTC):
11564
a6547ff97ce0 Allow tests to override pyramid_settings
Christophe de Vienne <christophe@unlish.com>
parents: 11514
diff changeset
     9
    settings = {}
a6547ff97ce0 Allow tests to override pyramid_settings
Christophe de Vienne <christophe@unlish.com>
parents: 11514
diff changeset
    10
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    11
    @classmethod
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    12
    def init_config(cls, config):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    13
        super(PyramidCWTest, cls).init_config(config)
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    14
        config.global_set_option('anonymous-user', 'anon')
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    15
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    16
    def setUp(self):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    17
        # Skip CubicWebTestTC setUp
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    18
        super(CubicWebTestTC, self).setUp()
11958
950ce7d9f642 [pyramid] Rename make_cubicweb_application function as config_from_cwconfig
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11913
diff changeset
    19
        config = config_from_cwconfig(self.config, self.settings)
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    20
        self.includeme(config)
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    21
        self.pyr_registry = config.registry
11593
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    22
        self.webapp = webtest.TestApp(
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    23
            config.make_wsgi_app(),
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    24
            extra_environ={'wsgi.url_scheme': 'https'})
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    25
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    26
    def includeme(self, config):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    27
        pass