1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import webtest
from webtest.debugapp import debug_app
from tests.compat import unittest
class TestEnviron(unittest.TestCase):
def test_get_extra_environ(self):
app = webtest.TestApp(debug_app,
extra_environ={'HTTP_ACCEPT_LANGUAGE': 'ru',
'foo': 'bar'})
res = app.get('http://localhost/')
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'bar'", res, res)
res = app.get('http://localhost/', extra_environ={'foo': 'baz'})
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'baz'", res, res)
def test_post_extra_environ(self):
app = webtest.TestApp(debug_app,
extra_environ={'HTTP_ACCEPT_LANGUAGE': 'ru',
'foo': 'bar'})
res = app.post('http://localhost/')
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'bar'", res, res)
res = app.post('http://localhost/', extra_environ={'foo': 'baz'})
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'baz'", res, res)
def test_request_extra_environ(self):
app = webtest.TestApp(debug_app,
extra_environ={'HTTP_ACCEPT_LANGUAGE': 'ru',
'foo': 'bar'})
res = app.request('http://localhost/', method='GET')
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'bar'", res, res)
res = app.request('http://localhost/', method='GET',
environ={'foo': 'baz'})
self.assertIn('HTTP_ACCEPT_LANGUAGE: ru', res, res)
self.assertIn("foo: 'baz'", res, res)
|