equal
deleted
inserted
replaced
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
21 __docformat__ = "restructuredtext en" |
21 __docformat__ = "restructuredtext en" |
22 |
22 |
23 from logilab.database import get_db_helper |
23 from logilab.database import get_db_helper |
24 |
24 |
25 from cubicweb.req import RequestSessionBase |
25 from cubicweb.req import RequestSessionBase |
26 from cubicweb.cwvreg import CubicWebVRegistry |
26 from cubicweb.cwvreg import CWRegistryStore |
27 from cubicweb.web.request import CubicWebRequestBase |
27 from cubicweb.web.request import CubicWebRequestBase |
28 from cubicweb.web.http_headers import Headers |
28 from cubicweb.web.http_headers import Headers |
29 |
29 |
30 from cubicweb.devtools import BASE_URL, BaseApptestConfiguration |
30 from cubicweb.devtools import BASE_URL, BaseApptestConfiguration |
31 |
31 |
32 |
32 |
33 class FakeConfig(dict, BaseApptestConfiguration): |
33 class FakeConfig(dict, BaseApptestConfiguration): |
34 translations = {} |
34 translations = {} |
35 uiprops = {} |
35 uiprops = {} |
36 apphome = None |
36 apphome = None |
|
37 debugmode = False |
37 def __init__(self, appid='data', apphome=None, cubes=()): |
38 def __init__(self, appid='data', apphome=None, cubes=()): |
38 self.appid = appid |
39 self.appid = appid |
39 self.apphome = apphome |
40 self.apphome = apphome |
40 self._cubes = cubes |
41 self._cubes = cubes |
41 self['auth-mode'] = 'cookie' |
42 self['auth-mode'] = 'cookie' |
54 class FakeRequest(CubicWebRequestBase): |
55 class FakeRequest(CubicWebRequestBase): |
55 """test implementation of an cubicweb request object""" |
56 """test implementation of an cubicweb request object""" |
56 |
57 |
57 def __init__(self, *args, **kwargs): |
58 def __init__(self, *args, **kwargs): |
58 if not (args or 'vreg' in kwargs): |
59 if not (args or 'vreg' in kwargs): |
59 kwargs['vreg'] = CubicWebVRegistry(FakeConfig(), initlog=False) |
60 kwargs['vreg'] = CWRegistryStore(FakeConfig(), initlog=False) |
60 kwargs['https'] = False |
61 kwargs['https'] = False |
61 self._url = kwargs.pop('url', None) or 'view?rql=Blop&vid=blop' |
62 self._url = kwargs.pop('url', None) or 'view?rql=Blop&vid=blop' |
62 super(FakeRequest, self).__init__(*args, **kwargs) |
63 super(FakeRequest, self).__init__(*args, **kwargs) |
63 self._session_data = {} |
64 self._session_data = {} |
64 self._headers_in = Headers() |
65 self._headers_in = Headers() |
142 def __init__(self, repo=None, user=None, vreg=None): |
143 def __init__(self, repo=None, user=None, vreg=None): |
143 self.repo = repo |
144 self.repo = repo |
144 if vreg is None: |
145 if vreg is None: |
145 vreg = getattr(self.repo, 'vreg', None) |
146 vreg = getattr(self.repo, 'vreg', None) |
146 if vreg is None: |
147 if vreg is None: |
147 vreg = CubicWebVRegistry(FakeConfig(), initlog=False) |
148 vreg = CWRegistryStore(FakeConfig(), initlog=False) |
148 self.vreg = vreg |
149 self.vreg = vreg |
149 self.cnxset = FakeConnectionsSet() |
150 self.cnxset = FakeConnectionsSet() |
150 self.user = user or FakeUser() |
151 self.user = user or FakeUser() |
151 self.is_internal_session = False |
152 self.is_internal_session = False |
152 self.transaction_data = {} |
153 self.transaction_data = {} |
177 self.extids = {} |
178 self.extids = {} |
178 self.eids = {} |
179 self.eids = {} |
179 self._count = 0 |
180 self._count = 0 |
180 self.schema = schema |
181 self.schema = schema |
181 self.config = config or FakeConfig() |
182 self.config = config or FakeConfig() |
182 self.vreg = vreg or CubicWebVRegistry(self.config, initlog=False) |
183 self.vreg = vreg or CWRegistryStore(self.config, initlog=False) |
183 self.vreg.schema = schema |
184 self.vreg.schema = schema |
184 self.sources = [] |
185 self.sources = [] |
185 |
186 |
186 def internal_session(self): |
187 def internal_session(self): |
187 return FakeSession(self) |
188 return FakeSession(self) |