17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
19 from logilab.common.testlib import unittest_main |
19 from logilab.common.testlib import unittest_main |
20 |
20 |
21 from cubicweb.devtools.testlib import CubicWebTC |
21 from cubicweb.devtools.testlib import CubicWebTC |
|
22 from cubicweb.web.views import actions, uicfg |
22 |
23 |
23 class ActionsTC(CubicWebTC): |
24 class ActionsTC(CubicWebTC): |
24 def test_view_action(self): |
25 def test_view_action(self): |
25 req = self.request(vid='rss', rql='CWUser X') |
26 req = self.request(vid='rss', rql='CWUser X') |
26 rset = self.execute('CWUser X') |
27 rset = self.execute('CWUser X') |
27 actions = self.vreg['actions'].poss_visible_objects(req, rset=rset) |
28 actions = self.vreg['actions'].poss_visible_objects(req, rset=rset) |
28 vaction = [action for action in actions if action.__regid__ == 'view'][0] |
29 vaction = [action for action in actions if action.__regid__ == 'view'][0] |
29 self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X') |
30 self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X') |
30 |
31 |
|
32 def test_has_editable_relations(self): |
|
33 """ensure has_editable_relation predicate used by ModifyAction |
|
34 return positive score if there is only some inlined forms |
|
35 """ |
|
36 use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress'] |
|
37 with self.temporary_permissions((use_email, {'add': ('guests',)}), |
|
38 ): |
|
39 with self.login('anon'): |
|
40 req = self.request() |
|
41 predicate = actions.has_editable_relation() |
|
42 self.assertEqual(predicate(None, req, rset=req.user.as_rset()), |
|
43 1) |
31 |
44 |
32 if __name__ == '__main__': |
45 if __name__ == '__main__': |
33 unittest_main() |
46 unittest_main() |