hooks/test/unittest_hooks.py
changeset 9935 d1adf549d5cb
parent 9853 4ddae5c156f6
child 10085 dc315002a2d4
child 10182 116b24efad0e
equal deleted inserted replaced
9934:e32964e28a45 9935:d1adf549d5cb
   120     def test_metadata_created_by(self):
   120     def test_metadata_created_by(self):
   121         with self.admin_access.repo_cnx() as cnx:
   121         with self.admin_access.repo_cnx() as cnx:
   122             entity = cnx.create_entity('Bookmark', title=u'wf1', path=u'/view')
   122             entity = cnx.create_entity('Bookmark', title=u'wf1', path=u'/view')
   123             cnx.commit() # fire operations
   123             cnx.commit() # fire operations
   124             self.assertEqual(len(entity.created_by), 1) # make sure we have only one creator
   124             self.assertEqual(len(entity.created_by), 1) # make sure we have only one creator
   125             self.assertEqual(entity.created_by[0].eid, self.session.user.eid)
   125             self.assertEqual(entity.created_by[0].eid, cnx.user.eid)
   126 
   126 
   127     def test_metadata_owned_by(self):
   127     def test_metadata_owned_by(self):
   128         with self.admin_access.repo_cnx() as cnx:
   128         with self.admin_access.repo_cnx() as cnx:
   129             entity = cnx.create_entity('Bookmark', title=u'wf1', path=u'/view')
   129             entity = cnx.create_entity('Bookmark', title=u'wf1', path=u'/view')
   130             cnx.commit() # fire operations
   130             cnx.commit() # fire operations
   131             self.assertEqual(len(entity.owned_by), 1) # make sure we have only one owner
   131             self.assertEqual(len(entity.owned_by), 1) # make sure we have only one owner
   132             self.assertEqual(entity.owned_by[0].eid, self.session.user.eid)
   132             self.assertEqual(entity.owned_by[0].eid, cnx.user.eid)
   133 
   133 
   134     def test_user_login_stripped(self):
   134     def test_user_login_stripped(self):
   135         with self.admin_access.repo_cnx() as cnx:
   135         with self.admin_access.repo_cnx() as cnx:
   136             u = self.create_user(cnx, '  joe  ')
   136             u = self.create_user(cnx, '  joe  ')
   137             tname = cnx.execute('Any L WHERE E login L, E eid %(e)s',
   137             tname = cnx.execute('Any L WHERE E login L, E eid %(e)s',
   151             self.create_user(cnx, 'toto', password='hop', commit=False)
   151             self.create_user(cnx, 'toto', password='hop', commit=False)
   152             self.assertRaises(AuthenticationError,
   152             self.assertRaises(AuthenticationError,
   153                               self.repo.connect, u'toto', password='hop')
   153                               self.repo.connect, u'toto', password='hop')
   154             cnx.commit()
   154             cnx.commit()
   155             cnxid = self.repo.connect(u'toto', password='hop')
   155             cnxid = self.repo.connect(u'toto', password='hop')
   156             self.assertNotEqual(cnxid, self.session.id)
   156             self.assertNotEqual(cnxid, cnx.sessionid)
   157             cnx.execute('DELETE CWUser X WHERE X login "toto"')
   157             cnx.execute('DELETE CWUser X WHERE X login "toto"')
   158             self.repo.execute(cnxid, 'State X')
   158             self.repo.execute(cnxid, 'State X')
   159             cnx.commit()
   159             cnx.commit()
   160             self.assertRaises(BadConnectionId,
   160             self.assertRaises(BadConnectionId,
   161                               self.repo.execute, cnxid, 'State X')
   161                               self.repo.execute, cnxid, 'State X')