Commit f1ff4ca1 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Fix existing tests for storage's transactions manager.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1649 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 709eeefc
...@@ -23,7 +23,7 @@ from neo.storage.app import Application ...@@ -23,7 +23,7 @@ from neo.storage.app import Application
from neo.storage.handlers.master import MasterOperationHandler from neo.storage.handlers.master import MasterOperationHandler
from neo.exception import PrimaryFailure, OperationFailure from neo.exception import PrimaryFailure, OperationFailure
from neo.pt import PartitionTable from neo.pt import PartitionTable
from neo.protocol import CellStates, Packets, Packet from neo.protocol import CellStates, Packets, Packet, ProtocolError
from neo.protocol import INVALID_TID, INVALID_OID from neo.protocol import INVALID_TID, INVALID_OID
class StorageMasterHandlerTests(NeoTestBase): class StorageMasterHandlerTests(NeoTestBase):
...@@ -141,33 +141,47 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -141,33 +141,47 @@ class StorageMasterHandlerTests(NeoTestBase):
conn = Mock({ 'isServer': False }) conn = Mock({ 'isServer': False })
self.assertRaises(OperationFailure, self.operation.stopOperation, conn) self.assertRaises(OperationFailure, self.operation.stopOperation, conn)
def test_22_lockInformation2(self): def _getConnection(self):
# load transaction informations return Mock({})
conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ }) def test_lockInformation1(self):
transaction = Mock({ 'getObjectList': ((0, ), ), }) """ Unknown transaction """
self.app.transaction_dict[INVALID_TID] = transaction self.app.tm = Mock({'__contains__': False})
self.operation.lockInformation(conn, INVALID_TID) conn = self._getConnection()
self.assertEquals(self.app.load_lock_dict[0], INVALID_TID) tid = self.getNextTID()
calls = self.app.dm.mockGetNamedCalls('storeTransaction') handler = self.operation
self.assertEquals(len(calls), 1) self.assertRaises(ProtocolError, handler.lockInformation, conn, tid)
def test_lockInformation2(self):
""" Lock transaction """
self.app.tm = Mock({'__contains__': True})
conn = self._getConnection()
tid = self.getNextTID()
self.operation.lockInformation(conn, tid)
calls = self.app.tm.mockGetNamedCalls('lock')
self.assertEqual(len(calls), 1)
calls[0].checkArgs(tid)
self.checkAnswerInformationLocked(conn) self.checkAnswerInformationLocked(conn)
def test_23_notifyUnlockInformation2(self): def test_notifyUnlockInformation1(self):
# delete transaction informations """ Unknown transaction """
conn = Mock({ 'isServer': False, }) self.app.tm = Mock({'__contains__': False})
self.app.dm = Mock({ }) conn = self._getConnection()
transaction = Mock({ 'getObjectList': ((0, ), ), }) tid = self.getNextTID()
self.app.transaction_dict[INVALID_TID] = transaction handler = self.operation
self.app.load_lock_dict[0] = transaction self.assertRaises(ProtocolError, handler.notifyUnlockInformation,
self.app.store_lock_dict[0] = transaction conn, tid)
self.operation.notifyUnlockInformation(conn, INVALID_TID)
self.assertEquals(len(self.app.load_lock_dict), 0) def test_notifyUnlockInformation2(self):
self.assertEquals(len(self.app.store_lock_dict), 0) """ Unlock transaction """
self.assertEquals(len(self.app.store_lock_dict), 0) self.app.tm = Mock({'__contains__': True})
calls = self.app.dm.mockGetNamedCalls('finishTransaction') conn = self._getConnection()
self.assertEquals(len(calls), 1) tid = self.getNextTID()
calls[0].checkArgs(INVALID_TID) self.operation.notifyUnlockInformation(conn, tid)
calls = self.app.tm.mockGetNamedCalls('unlock')
self.assertEqual(len(calls), 1)
calls[0].checkArgs(tid)
self.checkNoPacketSent(conn)
def test_30_answerLastIDs(self): def test_30_answerLastIDs(self):
# set critical TID on replicator # set critical TID on replicator
......
...@@ -74,7 +74,7 @@ class StorageStorageHandlerTests(NeoTestBase): ...@@ -74,7 +74,7 @@ class StorageStorageHandlerTests(NeoTestBase):
# delayed response # delayed response
conn = Mock({}) conn = Mock({})
self.app.dm = Mock() self.app.dm = Mock()
packet = Packets.AskObject() self.app.tm = Mock({'loadLocked': True})
self.app.load_lock_dict[INVALID_OID] = object() self.app.load_lock_dict[INVALID_OID] = object()
self.assertEquals(len(self.app.event_queue), 0) self.assertEquals(len(self.app.event_queue), 0)
self.operation.askObject(conn, oid=INVALID_OID, self.operation.askObject(conn, oid=INVALID_OID,
......
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