equal
deleted
inserted
replaced
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """Fake objects to ease testing of cubicweb without a fully working environment |
18 """Fake objects to ease testing of cubicweb without a fully working environment |
19 """ |
19 """ |
20 |
20 |
21 from contextlib import contextmanager |
21 from contextlib import contextmanager |
22 |
|
23 from six import string_types |
|
24 |
22 |
25 from logilab.database import get_db_helper |
23 from logilab.database import get_db_helper |
26 |
24 |
27 from cubicweb.req import RequestSessionBase |
25 from cubicweb.req import RequestSessionBase |
28 from cubicweb.cwvreg import CWRegistryStore |
26 from cubicweb.cwvreg import CWRegistryStore |
96 return url |
94 return url |
97 return url.split('?', 1)[0] |
95 return url.split('?', 1)[0] |
98 |
96 |
99 def set_request_header(self, header, value, raw=False): |
97 def set_request_header(self, header, value, raw=False): |
100 """set an incoming HTTP header (for test purpose only)""" |
98 """set an incoming HTTP header (for test purpose only)""" |
101 if isinstance(value, string_types): |
99 if isinstance(value, str): |
102 value = [value] |
100 value = [value] |
103 if raw: |
101 if raw: |
104 # adding encoded header is important, else page content |
102 # adding encoded header is important, else page content |
105 # will be reconverted back to unicode and apart unefficiency, this |
103 # will be reconverted back to unicode and apart unefficiency, this |
106 # may cause decoding problem (e.g. when downloading a file) |
104 # may cause decoding problem (e.g. when downloading a file) |