pyramid_cubicweb/tests/__init__.py
author Julien Cristau <julien.cristau@logilab.fr>
Wed, 25 Nov 2015 12:32:59 +0100
changeset 11607 5b36399b6b21
parent 11606 e245680acce3
permissions -rw-r--r--
[bwcompat] also set response headers in error cases I had this sitting around in my local copy, I don't remember why I needed this but it seems correct.
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
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
     5
from pyramid_cubicweb import make_cubicweb_application
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('https-url', 'https://localhost.local/')
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    15
        config.global_set_option('anonymous-user', 'anon')
11593
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    16
        config.https_uiprops = None
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    17
        config.https_datadir_url = None
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    18
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    19
    def setUp(self):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    20
        # Skip CubicWebTestTC setUp
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    21
        super(CubicWebTestTC, self).setUp()
11564
a6547ff97ce0 Allow tests to override pyramid_settings
Christophe de Vienne <christophe@unlish.com>
parents: 11514
diff changeset
    22
        config = make_cubicweb_application(self.config, self.settings)
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    23
        self.includeme(config)
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    24
        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
    25
        self.webapp = webtest.TestApp(
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    26
            config.make_wsgi_app(),
73bf8377a3d5 [auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents: 11564
diff changeset
    27
            extra_environ={'wsgi.url_scheme': 'https'})
11514
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    28
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    29
    def includeme(self, config):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    30
        pass