author | Arthur Lutz <arthur.lutz@logilab.fr> |
Fri, 31 Jan 2020 15:13:14 +0100 | |
branch | 3.27 |
changeset 12854 | 87c94f2a3103 |
parent 12593 | c30f8dc81f22 |
permissions | -rw-r--r-- |
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 |
|
11971
6c035cfef04f
[pyramid] Use existing repo in PyramidCWTest
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11958
diff
changeset
|
3 |
from pyramid.config import Configurator |
11514
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
4 |
from cubicweb.devtools.webtest import CubicWebTestTC |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
5 |
|
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 |
class PyramidCWTest(CubicWebTestTC): |
11564
a6547ff97ce0
Allow tests to override pyramid_settings
Christophe de Vienne <christophe@unlish.com>
parents:
11514
diff
changeset
|
8 |
settings = {} |
a6547ff97ce0
Allow tests to override pyramid_settings
Christophe de Vienne <christophe@unlish.com>
parents:
11514
diff
changeset
|
9 |
|
11514
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
10 |
@classmethod |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
11 |
def init_config(cls, config): |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
12 |
super(PyramidCWTest, cls).init_config(config) |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
13 |
config.global_set_option('anonymous-user', 'anon') |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
14 |
|
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
15 |
def setUp(self): |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
16 |
# Skip CubicWebTestTC setUp |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
17 |
super(CubicWebTestTC, self).setUp() |
12593
c30f8dc81f22
Fix pyramid tests
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
12088
diff
changeset
|
18 |
settings = { |
c30f8dc81f22
Fix pyramid tests
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
12088
diff
changeset
|
19 |
'cubicweb.bwcompat': False, |
c30f8dc81f22
Fix pyramid tests
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
12088
diff
changeset
|
20 |
'cubicweb.session.secret': 'test', |
c30f8dc81f22
Fix pyramid tests
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
12088
diff
changeset
|
21 |
} |
12088
477a59a45786
[pyramid] disable bwcompat by default in PyramidCWTest
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
11971
diff
changeset
|
22 |
settings.update(self.settings) |
477a59a45786
[pyramid] disable bwcompat by default in PyramidCWTest
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
11971
diff
changeset
|
23 |
config = Configurator(settings=settings) |
11971
6c035cfef04f
[pyramid] Use existing repo in PyramidCWTest
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11958
diff
changeset
|
24 |
config.registry['cubicweb.repository'] = self.repo |
6c035cfef04f
[pyramid] Use existing repo in PyramidCWTest
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11958
diff
changeset
|
25 |
config.include('cubicweb.pyramid') |
11514
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
26 |
self.includeme(config) |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
27 |
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
|
28 |
self.webapp = webtest.TestApp( |
73bf8377a3d5
[auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents:
11564
diff
changeset
|
29 |
config.make_wsgi_app(), |
73bf8377a3d5
[auth] Authtkt http_only and secure by default
Christophe de Vienne <cdevienne@gmail.com>
parents:
11564
diff
changeset
|
30 |
extra_environ={'wsgi.url_scheme': 'https'}) |
11514
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
31 |
|
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
32 |
def includeme(self, config): |
82e86cd8e217
Move PyramidCWTest to pyramid_cubicweb.tests
Christophe de Vienne <christophe@unlish.com>
parents:
11508
diff
changeset
|
33 |
pass |