devtools/test/unittest_testlib.py
changeset 9472 ae97167956b1
parent 9402 2c48c091b6a2
child 9857 618d45655865
equal deleted inserted replaced
9471:367fe83d9f98 9472:ae97167956b1
   187         with self.temporary_appobjects(AnAppobject):
   187         with self.temporary_appobjects(AnAppobject):
   188             self.assertEqual(self.vreg['hip'], AnAppobject.registered)
   188             self.assertEqual(self.vreg['hip'], AnAppobject.registered)
   189             self.assertIn(AnAppobject, self.vreg['hip']['hop'])
   189             self.assertIn(AnAppobject, self.vreg['hip']['hop'])
   190         self.assertNotIn(AnAppobject, self.vreg['hip']['hop'])
   190         self.assertNotIn(AnAppobject, self.vreg['hip']['hop'])
   191 
   191 
       
   192     def test_login(self):
       
   193         """Calling login should not break self.session hook control"""
       
   194         self.hook_executed = False
       
   195         babar = self.create_user(self.request(), 'babar')
       
   196         self.commit()
       
   197 
       
   198         from cubicweb.server import hook
       
   199         from cubicweb.predicates import is_instance
       
   200 
       
   201         class MyHook(hook.Hook):
       
   202             __regid__ = 'whatever'
       
   203             __select__ = hook.Hook.__select__ & is_instance('CWProperty')
       
   204             category = 'test-hook'
       
   205             events = ('after_add_entity',)
       
   206             test = self
       
   207 
       
   208             def __call__(self):
       
   209                 self.test.hook_executed = True
       
   210 
       
   211         self.login('babar')
       
   212         with self.temporary_appobjects(MyHook):
       
   213             with self.session.allow_all_hooks_but('test-hook'):
       
   214                 req = self.request()
       
   215                 prop = req.create_entity('CWProperty', pkey=u'ui.language', value=u'en')
       
   216                 self.commit()
       
   217                 self.assertFalse(self.hook_executed)
       
   218 
   192 
   219 
   193 class RepoAccessTC(CubicWebTC):
   220 class RepoAccessTC(CubicWebTC):
   194     def test_repo_connection(self):
   221     def test_repo_connection(self):
   195         acc = self.new_access('admin')
   222         acc = self.new_access('admin')
   196         with  acc.repo_cnx() as cnx:
   223         with  acc.repo_cnx() as cnx: