equal
deleted
inserted
replaced
1 # copyright 2003-2010 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 |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """unittests for cw.devtools.testlib module""" |
18 """unittests for cw.devtools.testlib module""" |
|
19 from __future__ import with_statement |
19 |
20 |
20 from cStringIO import StringIO |
21 from cStringIO import StringIO |
21 |
22 |
22 from unittest import TextTestRunner |
23 from unittest import TextTestRunner |
23 from logilab.common.testlib import TestSuite, TestCase, unittest_main |
24 from logilab.common.testlib import TestSuite, TestCase, unittest_main |
153 """test has_link_regexp()""" |
154 """test has_link_regexp()""" |
154 self.assertEqual(self.page_info.has_link_regexp('L[oi]gilab'), True) |
155 self.assertEqual(self.page_info.has_link_regexp('L[oi]gilab'), True) |
155 self.assertEqual(self.page_info.has_link_regexp('L[ai]gilab'), False) |
156 self.assertEqual(self.page_info.has_link_regexp('L[ai]gilab'), False) |
156 |
157 |
157 |
158 |
|
159 class CWUtilitiesTC(CubicWebTC): |
|
160 def test_temporary_permissions_eschema(self): |
|
161 eschema = self.schema['CWUser'] |
|
162 with self.temporary_permissions(CWUser={'read': ()}): |
|
163 self.assertEqual(eschema.permissions['read'], ()) |
|
164 self.assertTrue(eschema.permissions['add']) |
|
165 self.assertTrue(eschema.permissions['read'], ()) |
|
166 |
|
167 def test_temporary_permissions_rdef(self): |
|
168 rdef = self.schema['CWUser'].rdef('in_group') |
|
169 with self.temporary_permissions((rdef, {'read': ()})): |
|
170 self.assertEqual(rdef.permissions['read'], ()) |
|
171 self.assertTrue(rdef.permissions['add']) |
|
172 self.assertTrue(rdef.permissions['read'], ()) |
|
173 |
158 if __name__ == '__main__': |
174 if __name__ == '__main__': |
159 unittest_main() |
175 unittest_main() |