server/test/unittest_repository.py
branchstable
changeset 7339 dd5e49a5dcab
parent 7238 576abb8c4626
child 7343 977a49472806
equal deleted inserted replaced
7337:67cd9d5b4c2e 7339:dd5e49a5dcab
   275     def test_close_kill_processing_request(self):
   275     def test_close_kill_processing_request(self):
   276         repo = self.repo
   276         repo = self.repo
   277         cnxid = repo.connect(self.admlogin, password=self.admpassword)
   277         cnxid = repo.connect(self.admlogin, password=self.admpassword)
   278         repo.execute(cnxid, 'INSERT CWUser X: X login "toto", X upassword "tutu", X in_group G WHERE G name "users"')
   278         repo.execute(cnxid, 'INSERT CWUser X: X login "toto", X upassword "tutu", X in_group G WHERE G name "users"')
   279         repo.commit(cnxid)
   279         repo.commit(cnxid)
       
   280         lock = threading.Lock(), threading.Lock()
       
   281         lock.acquire()
   280         # close has to be in the thread due to sqlite limitations
   282         # close has to be in the thread due to sqlite limitations
   281         def close_in_a_few_moment():
   283         def close_in_a_few_moment():
   282             time.sleep(0.1)
   284             lock.acquire()
   283             repo.close(cnxid)
   285             repo.close(cnxid)
   284         t = threading.Thread(target=close_in_a_few_moment)
   286         t = threading.Thread(target=close_in_a_few_moment)
   285         t.start()
   287         t.start()
   286         def run_transaction():
   288         def run_transaction():
       
   289             lock.release()
   287             repo.execute(cnxid, 'DELETE CWUser X WHERE X login "toto"')
   290             repo.execute(cnxid, 'DELETE CWUser X WHERE X login "toto"')
   288             repo.commit(cnxid)
   291             repo.commit(cnxid)
   289         try:
   292         try:
   290             with self.assertRaises(Exception) as cm:
   293             with self.assertRaises(Exception) as cm:
   291                 run_transaction()
   294                 run_transaction()