11 import simplejson |
11 import simplejson |
12 |
12 |
13 from logilab.common.testlib import TestCase |
13 from logilab.common.testlib import TestCase |
14 from logilab.common.pytest import nocoverage |
14 from logilab.common.pytest import nocoverage |
15 from logilab.common.umessage import message_from_string |
15 from logilab.common.umessage import message_from_string |
|
16 |
|
17 from logilab.common.deprecation import deprecated_function |
16 |
18 |
17 from cubicweb.devtools import init_test_database, TestServerConfiguration, ApptestConfiguration |
19 from cubicweb.devtools import init_test_database, TestServerConfiguration, ApptestConfiguration |
18 from cubicweb.devtools._apptest import TestEnvironment |
20 from cubicweb.devtools._apptest import TestEnvironment |
19 from cubicweb.devtools.fake import FakeRequest |
21 from cubicweb.devtools.fake import FakeRequest |
20 |
22 |
216 return sorted((a.id, a.__class__) for a in self.vreg.possible_views(req, rset)) |
218 return sorted((a.id, a.__class__) for a in self.vreg.possible_views(req, rset)) |
217 |
219 |
218 def pactions(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): |
220 def pactions(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): |
219 return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) |
221 return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) |
220 if a.category not in skipcategories] |
222 if a.category not in skipcategories] |
|
223 |
|
224 def pactions_by_cats(self, req, rset, categories=('addrelated',)): |
|
225 return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) |
|
226 if a.category in categories] |
|
227 |
|
228 paddrelactions = deprecated_function(pactions_by_cats) |
|
229 |
221 def pactionsdict(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): |
230 def pactionsdict(self, req, rset, skipcategories=('addrelated', 'siteactions', 'useractions')): |
222 res = {} |
231 res = {} |
223 for a in self.vreg.possible_vobjects('actions', req, rset): |
232 for a in self.vreg.possible_vobjects('actions', req, rset): |
224 if a.category not in skipcategories: |
233 if a.category not in skipcategories: |
225 res.setdefault(a.category, []).append(a.__class__) |
234 res.setdefault(a.category, []).append(a.__class__) |
226 return res |
235 return res |
227 |
236 |
228 def paddrelactions(self, req, rset): |
237 |
229 return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) |
|
230 if a.category == 'addrelated'] |
|
231 |
|
232 def pmainactions(self, req, rset): |
|
233 return [(a.id, a.__class__) for a in self.vreg.possible_vobjects('actions', req, rset) |
|
234 if a.category == 'mainactions'] |
|
235 |
|
236 def remote_call(self, fname, *args): |
238 def remote_call(self, fname, *args): |
237 """remote call simulation""" |
239 """remote call simulation""" |
238 dump = simplejson.dumps |
240 dump = simplejson.dumps |
239 args = [dump(arg) for arg in args] |
241 args = [dump(arg) for arg in args] |
240 req = self.request(mode='remote', fname=fname, pageid='123', arg=args) |
242 req = self.request(mode='remote', fname=fname, pageid='123', arg=args) |