1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2014 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 from cubicweb.devtools.testlib import CubicWebTC |
21 from cubicweb.devtools.testlib import CubicWebTC |
22 from cubicweb.web.views import actions, uicfg |
22 from cubicweb.web.views import actions, uicfg |
23 |
23 |
24 class ActionsTC(CubicWebTC): |
24 class ActionsTC(CubicWebTC): |
25 def test_view_action(self): |
25 def test_view_action(self): |
26 req = self.request(vid='rss', rql='CWUser X') |
26 with self.admin_access.web_request(vid='rss', rql='CWUser X') as req: |
27 rset = self.execute('CWUser X') |
27 rset = req.execute('CWUser X') |
28 actions = self.vreg['actions'].poss_visible_objects(req, rset=rset) |
28 actions = self.vreg['actions'].poss_visible_objects(req, rset=rset) |
29 vaction = [action for action in actions if action.__regid__ == 'view'][0] |
29 vaction = [action for action in actions if action.__regid__ == 'view'][0] |
30 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') |
31 |
31 |
32 def test_has_editable_relations(self): |
32 def test_has_editable_relations(self): |
33 """ensure has_editable_relation predicate used by ModifyAction |
33 """ensure has_editable_relation predicate used by ModifyAction |
34 return positive score if there is only some inlined forms |
34 return positive score if there is only some inlined forms |
35 """ |
35 """ |
36 use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress'] |
36 use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress'] |
37 with self.temporary_permissions((use_email, {'add': ('guests',)}), |
37 with self.temporary_permissions((use_email, {'add': ('guests',)})): |
38 ): |
38 with self.new_access('anon').web_request() as req: |
39 with self.login('anon'): |
|
40 req = self.request() |
|
41 predicate = actions.has_editable_relation() |
39 predicate = actions.has_editable_relation() |
42 self.assertEqual(predicate(None, req, rset=req.user.as_rset()), |
40 self.assertEqual(predicate(None, req, rset=req.user.as_rset()), |
43 1) |
41 1) |
44 |
42 |
45 if __name__ == '__main__': |
43 if __name__ == '__main__': |