author | Christophe de Vienne <christophe@unlish.com> |
Thu, 24 Jul 2014 20:57:14 +0200 | |
changeset 9940 | 292f786009ba |
parent 9939 | 46a8ed48636f |
child 9941 | 8dc1c96d29f1 |
permissions | -rw-r--r-- |
9939
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
1 |
import webtest.app |
9940
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
2 |
from StringIO import StringIO |
9939
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
3 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
4 |
from cubicweb.devtools.webtest import CubicWebTestTC |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
5 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
6 |
from cubicweb.wsgi.request import CubicWebWsgiRequest |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
7 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
8 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
9 |
class WSGIAppTC(CubicWebTestTC): |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
10 |
def test_content_type(self): |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
11 |
r = webtest.app.TestRequest.blank('/', {'CONTENT_TYPE': 'text/plain'}) |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
12 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
13 |
req = CubicWebWsgiRequest(r.environ, self.vreg) |
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
14 |
|
46a8ed48636f
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
Christophe de Vienne <christophe@unlish.com>
parents:
diff
changeset
|
15 |
self.assertEqual('text/plain', req.get_header('Content-Type')) |
9940
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
16 |
|
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
17 |
def test_content_body(self): |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
18 |
r = webtest.app.TestRequest.blank('/', { |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
19 |
'CONTENT_LENGTH': 12, |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
20 |
'CONTENT_TYPE': 'text/plain', |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
21 |
'wsgi.input': StringIO('some content')}) |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
22 |
|
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
23 |
req = CubicWebWsgiRequest(r.environ, self.vreg) |
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
24 |
|
292f786009ba
[wsgi] Re-set the request content after calling the inherited constructor.
Christophe de Vienne <christophe@unlish.com>
parents:
9939
diff
changeset
|
25 |
self.assertEqual('some content', req.content.read()) |