Commit 3149c554 authored by Vincent Pelletier's avatar Vincent Pelletier

Restore msg id.

This fixes cases where storage tries to answer a request after executing
queued events. This cannto happen with current code, but will happen in
near future.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2574 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 5a59f60b
......@@ -329,8 +329,10 @@ class Application(object):
some_callable, msg_id, conn, args = p()
if conn.isAborted() or conn.isClosed():
continue
orig_msg_id = conn.getPeerId()
conn.setPeerId(msg_id)
some_callable(conn, *args)
conn.setPeerId(orig_msg_id)
def logQueuedEvents(self):
if self.event_queue is None:
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import unittest
from mock import Mock
from mock import Mock, ReturnValues
from neo.tests import NeoUnitTestBase
from neo.storage.app import Application
from neo.protocol import CellStates
......@@ -131,8 +131,9 @@ class StorageAppTests(NeoUnitTestBase):
def test_03_executeQueuedEvents(self):
self.assertEqual(len(self.app.event_queue), 0)
msg_id = 1325136
msg_id_2 = 1325137
event = Mock({'__repr__': 'event'})
conn = Mock({'__repr__': 'conn', 'getPeerId': msg_id})
conn = Mock({'__repr__': 'conn', 'getPeerId': ReturnValues(msg_id, msg_id_2)})
self.app.queueEvent(event, conn, "test")
self.app.executeQueuedEvents()
self.assertEquals(len(event.mockGetNamedCalls("__call__")), 1)
......@@ -141,6 +142,10 @@ class StorageAppTests(NeoUnitTestBase):
self.assertEqual(params, "test")
params = call.kwparams
self.assertEqual(params, {})
calls = conn.mockGetNamedCalls("setPeerId")
self.assertEqual(len(calls), 2)
calls[0].checkArgs(msg_id)
calls[1].checkArgs(msg_id_2)
if __name__ == '__main__':
unittest.main()
......
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