details:   https://code.tryton.org/tryton/commit/14eb1965bca1
branch:    default
user:      Nicolas Évrard <[email protected]>
date:      Sat Jun 14 03:21:40 2025 +0200
description:
        Test the restoration of history after a DELETE
diffstat:

 trytond/trytond/tests/test_history.py |  24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diffs (34 lines):

diff -r f5d236a74873 -r 14eb1965bca1 trytond/trytond/tests/test_history.py
--- a/trytond/trytond/tests/test_history.py     Fri Oct 17 16:27:11 2025 +0200
+++ b/trytond/trytond/tests/test_history.py     Sat Jun 14 03:21:40 2025 +0200
@@ -191,6 +191,30 @@
             History.read([history_id], ['value'])
 
     @with_transaction()
+    def test_restore_history_after_delete(self):
+        "Test restoring a record after deleting it"
+        pool = Pool()
+        History = pool.get('test.history')
+        transaction = Transaction()
+
+        history = History(value=1)
+        history.save()
+        history_id = history.id
+        first = history.create_date
+
+        transaction.commit()
+
+        History.delete([History(history_id)])
+        with self.assertRaises(AccessError):
+            History.read([history_id], ['value'])
+
+        transaction.commit()
+
+        History.restore_history([history_id], first)
+        history = History(history_id)
+        self.assertEqual(history.value, 1)
+
+    @with_transaction()
     def test_restore_history_before(self):
         'Test restore history before'
         pool = Pool()

Reply via email to