17 # You should have received a copy of the GNU Lesser General Public License along |
17 # You should have received a copy of the GNU Lesser General Public License along |
18 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
19 |
19 |
20 from cubicweb import ValidationError |
20 from cubicweb import ValidationError |
21 from cubicweb.devtools.testlib import CubicWebTC |
21 from cubicweb.devtools.testlib import CubicWebTC |
|
22 import cubicweb.server.session |
|
23 from cubicweb.server.session import Transaction as OldTransaction |
22 from cubicweb.transaction import * |
24 from cubicweb.transaction import * |
23 |
25 |
24 from cubicweb.server.sources.native import UndoTransactionException, _UndoException |
26 from cubicweb.server.sources.native import UndoTransactionException, _UndoException |
25 |
27 |
26 |
28 |
27 class UndoableTransactionTC(CubicWebTC): |
29 class UndoableTransactionTC(CubicWebTC): |
28 |
30 |
29 def setup_database(self): |
31 def setup_database(self): |
30 req = self.request() |
32 req = self.request() |
31 self.session.undo_actions = True |
|
32 self.toto = self.create_user(req, 'toto', password='toto', groups=('users',), |
33 self.toto = self.create_user(req, 'toto', password='toto', groups=('users',), |
33 commit=False) |
34 commit=False) |
34 self.txuuid = self.commit() |
35 self.txuuid = self.commit() |
35 |
36 |
|
37 def setUp(self): |
|
38 class Transaction(OldTransaction): |
|
39 """Force undo feature to be turned on in all case""" |
|
40 undo_actions = property(lambda tx: True, lambda x, y:None) |
|
41 cubicweb.server.session.Transaction = Transaction |
|
42 super(UndoableTransactionTC, self).setUp() |
|
43 |
36 def tearDown(self): |
44 def tearDown(self): |
|
45 cubicweb.server.session.Transaction = OldTransaction |
37 self.restore_connection() |
46 self.restore_connection() |
38 self.session.undo_support = set() |
47 self.session.undo_support = set() |
39 super(UndoableTransactionTC, self).tearDown() |
48 super(UndoableTransactionTC, self).tearDown() |
40 |
49 |
41 def check_transaction_deleted(self, txuuid): |
50 def check_transaction_deleted(self, txuuid): |