[Neo-report] r1862 vincent - in /trunk/neo: client/app.py tests/client/testClientApp.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Feb 25 17:37:50 CET 2010
Author: vincent
Date: Thu Feb 25 17:37:48 2010
New Revision: 1862
Log:
Don't refuse undoing object creation, except for root object.
Modified:
trunk/neo/client/app.py
trunk/neo/tests/client/testClientApp.py
Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Thu Feb 25 17:37:48 2010
@@ -808,8 +808,12 @@
try:
result = self.loadBefore(oid, transaction_id)
except NEOStorageNotFoundError:
- # no previous revision, can't undo (as in filestorage)
- raise UndoError("no previous record", oid)
+ if oid == '\x00' * 8:
+ # Refuse undoing root object creation.
+ raise UndoError("no previous record", oid)
+ else:
+ # Undo object creation
+ result = ('', None, transaction_id)
data, start, end = result
# end must be TID we are going to undone otherwise it means
# a later transaction modify the object
Modified: trunk/neo/tests/client/testClientApp.py
==============================================================================
--- trunk/neo/tests/client/testClientApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testClientApp.py [iso-8859-1] Thu Feb 25 17:37:48 2010
@@ -713,8 +713,7 @@
self.assertEquals(app.local_var.txn, old_txn)
def test_undo2(self):
- # Four tests here :
- # undo txn1 where obj1 was created -> fail
+ # Three tests here :
# undo txn2 where obj2 was modified in tid3 -> fail
# undo txn3 where there is a conflict on obj2
# undo txn3 where obj2 was altered from tid2 -> ok
@@ -722,13 +721,8 @@
app = self.getApp()
app.num_partitions = 2
oid1, oid2 = self.makeOID(1), self.makeOID(2)
- tid1, tid2 = self.makeTID(1), self.makeTID(2)
+ tid2 = self.makeTID(2)
tid3, tid4 = self.makeTID(3), self.makeTID(4)
- # commit version 1 of object 1
- txn1 = self.beginTransaction(app, tid=tid1)
- self.storeObject(app, oid=oid1, data='O1V1')
- self.voteTransaction(app)
- self.askFinishTransaction(app)
# commit version 1 of object 2
txn2 = self.beginTransaction(app, tid=tid2)
self.storeObject(app, oid=oid2, data='O1V2')
@@ -739,10 +733,6 @@
self.storeObject(app, oid=oid2, data='O2V2')
self.voteTransaction(app)
self.askFinishTransaction(app)
- # undo 1 -> no previous revision
- u1p1 = Packets.AnswerTransactionInformation(tid1, '', '', '',
- False, (oid1, ))
- u1p2 = Errors.OidNotFound('oid not found')
# undo 2 -> not end tid
u2p1 = Packets.AnswerTransactionInformation(tid2, '', '', '',
False, (oid2, ))
@@ -758,14 +748,13 @@
u4p2 = Packets.AnswerObject(oid2, tid3, tid3, 0, makeChecksum('O2V2'), 'O2V2')
u4p3 = Packets.AnswerStoreObject(conflicting=0, oid=oid2, serial=tid2)
# test logic
- packets = (u1p1, u1p2, u2p1, u2p2, u3p1, u3p2, u3p3, u4p1, u4p2, u4p3)
+ packets = (u2p1, u2p2, u3p1, u3p2, u3p3, u4p1, u4p2, u4p3)
for i, p in enumerate(packets):
p.setId(p)
storage_address = ('127.0.0.1', 10010)
conn = Mock({
'getNextId': 1,
'fakeReceived': ReturnValues(
- u1p1, u1p2,
u2p1, u2p2,
u4p1, u4p2,
u3p1, u3p2,
@@ -788,8 +777,6 @@
app.nm.createStorage(address=storage_address)
txn4 = self.beginTransaction(app, tid=tid4)
# all start here
- self.assertRaises(UndoError, app.undo, tid1, txn4,
- tryToResolveConflict)
self.assertRaises(UndoError, app.undo, tid2, txn4,
tryToResolveConflict)
app.local_var.queue.put((conn, u4p3))
More information about the Neo-report
mailing list