1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2013 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 |
18 """unittests for cw.devtools.testlib module""" |
18 """unittests for cw.devtools.testlib module""" |
19 |
19 |
20 from cStringIO import StringIO |
20 from cStringIO import StringIO |
21 |
21 |
22 from unittest import TextTestRunner |
22 from unittest import TextTestRunner |
|
23 |
23 from logilab.common.testlib import TestSuite, TestCase, unittest_main |
24 from logilab.common.testlib import TestSuite, TestCase, unittest_main |
|
25 from logilab.common.registry import yes |
24 |
26 |
25 from cubicweb.devtools import htmlparser |
27 from cubicweb.devtools import htmlparser |
26 from cubicweb.devtools.testlib import CubicWebTC |
28 from cubicweb.devtools.testlib import CubicWebTC |
27 from cubicweb.pytestconf import clean_repo_test_cls |
29 from cubicweb.pytestconf import clean_repo_test_cls |
28 |
30 |
170 with self.temporary_permissions((rdef, {'read': ()})): |
172 with self.temporary_permissions((rdef, {'read': ()})): |
171 self.assertEqual(rdef.permissions['read'], ()) |
173 self.assertEqual(rdef.permissions['read'], ()) |
172 self.assertTrue(rdef.permissions['add']) |
174 self.assertTrue(rdef.permissions['add']) |
173 self.assertTrue(rdef.permissions['read'], ()) |
175 self.assertTrue(rdef.permissions['read'], ()) |
174 |
176 |
|
177 def test_temporary_appobjects_registered(self): |
|
178 class AnAppobject(object): |
|
179 __registries__ = ('hip',) |
|
180 __regid__ = 'hop' |
|
181 __select__ = yes() |
|
182 registered = None |
|
183 @classmethod |
|
184 def __registered__(cls, reg): |
|
185 cls.registered = reg |
|
186 |
|
187 with self.temporary_appobjects(AnAppobject): |
|
188 self.assertEqual(self.vreg['hip'], AnAppobject.registered) |
|
189 self.assertIn(AnAppobject, self.vreg['hip']['hop']) |
|
190 self.assertNotIn(AnAppobject, self.vreg['hip']['hop']) |
|
191 |
|
192 |
175 class RepoAccessTC(CubicWebTC): |
193 class RepoAccessTC(CubicWebTC): |
176 |
|
177 def test_repo_connection(self): |
194 def test_repo_connection(self): |
178 acc = self.new_access('admin') |
195 acc = self.new_access('admin') |
179 with acc.repo_cnx() as cnx: |
196 with acc.repo_cnx() as cnx: |
180 rset = cnx.execute('Any X WHERE X is CWUser') |
197 rset = cnx.execute('Any X WHERE X is CWUser') |
181 self.assertTrue(rset) |
198 self.assertTrue(rset) |