pyramid_cubicweb/tests/__init__.py
author Christophe de Vienne <christophe@unlish.com>
Tue, 28 Apr 2015 11:04:03 +0200
changeset 11564 a6547ff97ce0
parent 11514 82e86cd8e217
child 11593 73bf8377a3d5
permissions -rw-r--r--
Allow tests to override pyramid_settings Closes #5307426
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')
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    16
        config['pyramid-auth-secret'] = 'authsecret'
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    17
        config['pyramid-session-secret'] = 'sessionsecret'
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
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    25
        self.webapp = webtest.TestApp(config.make_wsgi_app())
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    26
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    27
    def includeme(self, config):
82e86cd8e217 Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents: 11508
diff changeset
    28
        pass