equal
deleted
inserted
replaced
11 from logilab.common.adbh import get_adv_func_helper |
11 from logilab.common.adbh import get_adv_func_helper |
12 |
12 |
13 from indexer import get_indexer |
13 from indexer import get_indexer |
14 |
14 |
15 from cubicweb import RequestSessionMixIn |
15 from cubicweb import RequestSessionMixIn |
|
16 from cubicweb.cwvreg import CubicWebVRegistry |
16 from cubicweb.web.request import CubicWebRequestBase |
17 from cubicweb.web.request import CubicWebRequestBase |
17 from cubicweb.devtools import BASE_URL, BaseApptestConfiguration |
18 from cubicweb.devtools import BASE_URL, BaseApptestConfiguration |
18 |
19 |
19 |
20 |
20 class FakeConfig(dict, BaseApptestConfiguration): |
21 class FakeConfig(dict, BaseApptestConfiguration): |
65 class FakeRequest(CubicWebRequestBase): |
66 class FakeRequest(CubicWebRequestBase): |
66 """test implementation of an cubicweb request object""" |
67 """test implementation of an cubicweb request object""" |
67 |
68 |
68 def __init__(self, *args, **kwargs): |
69 def __init__(self, *args, **kwargs): |
69 if not (args or 'vreg' in kwargs): |
70 if not (args or 'vreg' in kwargs): |
70 kwargs['vreg'] = FakeVReg() |
71 kwargs['vreg'] = CubicWebVRegistry(FakeConfig(), initlog=False) |
71 kwargs['https'] = False |
72 kwargs['https'] = False |
72 self._url = kwargs.pop('url', 'view?rql=Blop&vid=blop') |
73 self._url = kwargs.pop('url', 'view?rql=Blop&vid=blop') |
73 super(FakeRequest, self).__init__(*args, **kwargs) |
74 super(FakeRequest, self).__init__(*args, **kwargs) |
74 self._session_data = {} |
75 self._session_data = {} |
75 self._headers = {} |
76 self._headers = {} |
175 |
176 |
176 |
177 |
177 class FakeSession(RequestSessionMixIn): |
178 class FakeSession(RequestSessionMixIn): |
178 def __init__(self, repo=None, user=None): |
179 def __init__(self, repo=None, user=None): |
179 self.repo = repo |
180 self.repo = repo |
180 self.vreg = getattr(self.repo, 'vreg', FakeVReg()) |
181 self.vreg = getattr(self.repo, 'vreg', CubicWebVRegistry(FakeConfig(), initlog=False)) |
181 self.pool = FakePool() |
182 self.pool = FakePool() |
182 self.user = user or FakeUser() |
183 self.user = user or FakeUser() |
183 self.is_internal_session = False |
184 self.is_internal_session = False |
184 self.is_super_session = self.user.eid == -1 |
185 self.is_super_session = self.user.eid == -1 |
185 self.transaction_data = {} |
186 self.transaction_data = {} |
208 def __init__(self, schema, vreg=None, config=None): |
209 def __init__(self, schema, vreg=None, config=None): |
209 self.extids = {} |
210 self.extids = {} |
210 self.eids = {} |
211 self.eids = {} |
211 self._count = 0 |
212 self._count = 0 |
212 self.schema = schema |
213 self.schema = schema |
213 self.vreg = vreg or FakeVReg() |
|
214 self.config = config or FakeConfig() |
214 self.config = config or FakeConfig() |
|
215 self.vreg = vreg or CubicWebVRegistry(self.config, initlog=False) |
|
216 self.vreg.schema = schema |
215 |
217 |
216 def internal_session(self): |
218 def internal_session(self): |
217 return FakeSession(self) |
219 return FakeSession(self) |
218 |
220 |
219 def extid2eid(self, source, extid, etype, session, insert=True, |
221 def extid2eid(self, source, extid, etype, session, insert=True, |