Commit e62c31b4 authored by Vincent Pelletier's avatar Vincent Pelletier

Do not raise ProtocolError, so error reaches app.

Also, don't expect setTransactionFinished/setTransactionVoted to be called.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2522 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent be9fdaa2
...@@ -168,7 +168,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler): ...@@ -168,7 +168,7 @@ class PrimaryAnswersHandler(AnswerBaseHandler):
def answerTransactionFinished(self, conn, tid): def answerTransactionFinished(self, conn, tid):
if tid != self.app.getTID(): if tid != self.app.getTID():
raise ProtocolError('Wrong TID, transaction not started') raise NEOStorageError('Wrong TID, transaction not started')
def answerPack(self, conn, status): def answerPack(self, conn, status):
if not status: if not status:
......
...@@ -93,7 +93,7 @@ class StorageAnswersHandler(AnswerBaseHandler): ...@@ -93,7 +93,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
def answerStoreTransaction(self, conn, tid): def answerStoreTransaction(self, conn, tid):
if tid != self.app.getTID(): if tid != self.app.getTID():
raise ProtocolError('Wrong TID, transaction not started') raise NEOStorageError('Wrong TID, transaction not started')
def answerTransactionInformation(self, conn, tid, def answerTransactionInformation(self, conn, tid,
user, desc, ext, packed, oid_list): user, desc, ext, packed, oid_list):
......
...@@ -247,14 +247,13 @@ class MasterAnswersHandlerTests(MasterHandlerTests): ...@@ -247,14 +247,13 @@ class MasterAnswersHandlerTests(MasterHandlerTests):
tid2 = self.getNextTID(tid1) tid2 = self.getNextTID(tid1)
# wrong TID # wrong TID
self.app = Mock({'getTID': tid1}) self.app = Mock({'getTID': tid1})
self.checkProtocolErrorRaised(self.handler.answerTransactionFinished, self.assertRaises(NEOStorageError,
self.handler.answerTransactionFinished,
conn, tid2) conn, tid2)
# matching TID # matching TID
app = Mock({'getTID': tid2}) app = Mock({'getTID': tid2})
handler = PrimaryAnswersHandler(app=app) handler = PrimaryAnswersHandler(app=app)
handler.answerTransactionFinished(conn, tid2) handler.answerTransactionFinished(conn, tid2)
calls = app.mockGetNamedCalls('setTransactionFinished')
self.assertEqual(len(calls), 1)
def test_answerPack(self): def test_answerPack(self):
self.assertRaises(NEOStorageError, self.handler.answerPack, None, False) self.assertRaises(NEOStorageError, self.handler.answerPack, None, False)
......
...@@ -182,14 +182,13 @@ class StorageAnswerHandlerTests(NeoUnitTestBase): ...@@ -182,14 +182,13 @@ class StorageAnswerHandlerTests(NeoUnitTestBase):
# wrong tid # wrong tid
app = Mock({'getTID': tid1}) app = Mock({'getTID': tid1})
handler = StorageAnswersHandler(app=app) handler = StorageAnswersHandler(app=app)
self.checkProtocolErrorRaised(handler.answerStoreTransaction, conn, self.assertRaises(NEOStorageError,
handler.answerStoreTransaction, conn,
tid2) tid2)
# good tid # good tid
app = Mock({'getTID': tid2}) app = Mock({'getTID': tid2})
handler = StorageAnswersHandler(app=app) handler = StorageAnswersHandler(app=app)
handler.answerStoreTransaction(conn, tid2) handler.answerStoreTransaction(conn, tid2)
calls = app.mockGetNamedCalls('setTransactionVoted')
self.assertEqual(len(calls), 1)
def test_answerTransactionInformation(self): def test_answerTransactionInformation(self):
conn = self.getConnection() conn = self.getConnection()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment