212 txs = cnx.undoable_transactions() |
212 txs = cnx.undoable_transactions() |
213 self.assertEqual(len(txs), 2) |
213 self.assertEqual(len(txs), 2) |
214 self.assertRaises(NoSuchTransaction, |
214 self.assertRaises(NoSuchTransaction, |
215 cnx.transaction_info, txuuid) |
215 cnx.transaction_info, txuuid) |
216 with self.admin_access.repo_cnx() as cnx: |
216 with self.admin_access.repo_cnx() as cnx: |
217 with cnx.ensure_cnx_set: |
217 self.check_transaction_deleted(cnx, txuuid) |
218 self.check_transaction_deleted(cnx, txuuid) |
|
219 # the final test: check we can login with the previously deleted user |
218 # the final test: check we can login with the previously deleted user |
220 with self.new_access('toto').client_cnx(): |
219 with self.new_access('toto').client_cnx(): |
221 pass |
220 pass |
222 |
221 |
223 def test_undo_deletion_integrity_1(self): |
222 def test_undo_deletion_integrity_1(self): |
271 cnx.commit() |
270 cnx.commit() |
272 self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': c.eid})) |
271 self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': c.eid})) |
273 self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': p.eid})) |
272 self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': p.eid})) |
274 self.assertFalse(cnx.execute('Any X,Y WHERE X fiche Y')) |
273 self.assertFalse(cnx.execute('Any X,Y WHERE X fiche Y')) |
275 with self.admin_access.repo_cnx() as cnx: |
274 with self.admin_access.repo_cnx() as cnx: |
276 with cnx.ensure_cnx_set: |
275 for eid in (p.eid, c.eid): |
277 for eid in (p.eid, c.eid): |
276 self.assertFalse(cnx.system_sql( |
278 self.assertFalse(cnx.system_sql( |
277 'SELECT * FROM entities WHERE eid=%s' % eid).fetchall()) |
279 'SELECT * FROM entities WHERE eid=%s' % eid).fetchall()) |
278 self.assertFalse(cnx.system_sql( |
280 self.assertFalse(cnx.system_sql( |
279 'SELECT 1 FROM owned_by_relation WHERE eid_from=%s' % eid).fetchall()) |
281 'SELECT 1 FROM owned_by_relation WHERE eid_from=%s' % eid).fetchall()) |
280 # added by sql in hooks (except when using dataimport) |
282 # added by sql in hooks (except when using dataimport) |
281 self.assertFalse(cnx.system_sql( |
283 self.assertFalse(cnx.system_sql( |
282 'SELECT 1 FROM is_relation WHERE eid_from=%s' % eid).fetchall()) |
284 'SELECT 1 FROM is_relation WHERE eid_from=%s' % eid).fetchall()) |
283 self.assertFalse(cnx.system_sql( |
285 self.assertFalse(cnx.system_sql( |
284 'SELECT 1 FROM is_instance_of_relation WHERE eid_from=%s' % eid).fetchall()) |
286 'SELECT 1 FROM is_instance_of_relation WHERE eid_from=%s' % eid).fetchall()) |
285 self.check_transaction_deleted(cnx, txuuid) |
287 self.check_transaction_deleted(cnx, txuuid) |
|
288 |
286 |
289 def test_undo_creation_integrity_1(self): |
287 def test_undo_creation_integrity_1(self): |
290 with self.admin_access.client_cnx() as cnx: |
288 with self.admin_access.client_cnx() as cnx: |
291 tutu = self.create_user(cnx, 'tutu', commit=False) |
289 tutu = self.create_user(cnx, 'tutu', commit=False) |
292 txuuid = cnx.commit() |
290 txuuid = cnx.commit() |
355 "Can't restore relation fiche, object entity %d doesn't exist anymore." % c.eid]) |
353 "Can't restore relation fiche, object entity %d doesn't exist anymore." % c.eid]) |
356 cnx.commit() |
354 cnx.commit() |
357 p.cw_clear_all_caches() |
355 p.cw_clear_all_caches() |
358 self.assertFalse(p.fiche) |
356 self.assertFalse(p.fiche) |
359 with self.admin_access.repo_cnx() as cnx: |
357 with self.admin_access.repo_cnx() as cnx: |
360 with cnx.ensure_cnx_set: |
358 self.assertIsNone(cnx.system_sql( |
361 self.assertIsNone(cnx.system_sql( |
359 'SELECT cw_fiche FROM cw_Personne WHERE cw_eid=%s' % p.eid).fetchall()[0][0]) |
362 'SELECT cw_fiche FROM cw_Personne WHERE cw_eid=%s' % p.eid).fetchall()[0][0]) |
|
363 |
360 |
364 def test_undo_inline_rel_add_ok(self): |
361 def test_undo_inline_rel_add_ok(self): |
365 """Undo add relation Personne (?) fiche (?) Card |
362 """Undo add relation Personne (?) fiche (?) Card |
366 |
363 |
367 Caution processed by `_undo_u`, not `_undo_a` !""" |
364 Caution processed by `_undo_u`, not `_undo_a` !""" |