Commit d3154a9d authored by Vincent Pelletier's avatar Vincent Pelletier

Call superclass' setUp & tearDown in unit tests.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2399 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 17a70c8e
...@@ -60,6 +60,7 @@ def failing_tryToResolveConflict(oid, conflict_serial, serial, data): ...@@ -60,6 +60,7 @@ def failing_tryToResolveConflict(oid, conflict_serial, serial, data):
class ClientApplicationTests(NeoUnitTestBase): class ClientApplicationTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# apply monkey patches # apply monkey patches
self._getMasterConnection = Application._getMasterConnection self._getMasterConnection = Application._getMasterConnection
self._waitMessage = Application._waitMessage self._waitMessage = Application._waitMessage
...@@ -73,6 +74,7 @@ class ClientApplicationTests(NeoUnitTestBase): ...@@ -73,6 +74,7 @@ class ClientApplicationTests(NeoUnitTestBase):
Application._getMasterConnection = self._getMasterConnection Application._getMasterConnection = self._getMasterConnection
Application._waitMessage = self._waitMessage Application._waitMessage = self._waitMessage
Application._getPartitionTable = self._getPartitionTable Application._getPartitionTable = self._getPartitionTable
NeoUnitTestBase.tearDown(self)
# some helpers # some helpers
......
...@@ -37,6 +37,7 @@ class MasterHandlerTests(NeoUnitTestBase): ...@@ -37,6 +37,7 @@ class MasterHandlerTests(NeoUnitTestBase):
class MasterBootstrapHandlerTests(MasterHandlerTests): class MasterBootstrapHandlerTests(MasterHandlerTests):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock() self.app = Mock()
self.handler = PrimaryBootstrapHandler(self.app) self.handler = PrimaryBootstrapHandler(self.app)
...@@ -136,6 +137,7 @@ class MasterBootstrapHandlerTests(MasterHandlerTests): ...@@ -136,6 +137,7 @@ class MasterBootstrapHandlerTests(MasterHandlerTests):
class MasterNotificationsHandlerTests(MasterHandlerTests): class MasterNotificationsHandlerTests(MasterHandlerTests):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.db = Mock() self.db = Mock()
self.app = Mock({'getDB': self.db}) self.app = Mock({'getDB': self.db})
self.app.nm = Mock() self.app.nm = Mock()
...@@ -221,6 +223,7 @@ class MasterNotificationsHandlerTests(MasterHandlerTests): ...@@ -221,6 +223,7 @@ class MasterNotificationsHandlerTests(MasterHandlerTests):
class MasterAnswersHandlerTests(MasterHandlerTests): class MasterAnswersHandlerTests(MasterHandlerTests):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock() self.app = Mock()
self.handler = PrimaryAnswersHandler(self.app) self.handler = PrimaryAnswersHandler(self.app)
......
...@@ -30,6 +30,7 @@ MARKER = [] ...@@ -30,6 +30,7 @@ MARKER = []
class StorageBootstrapHandlerTests(NeoUnitTestBase): class StorageBootstrapHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock() self.app = Mock()
self.handler = StorageBootstrapHandler(self.app) self.handler = StorageBootstrapHandler(self.app)
...@@ -67,6 +68,7 @@ class StorageBootstrapHandlerTests(NeoUnitTestBase): ...@@ -67,6 +68,7 @@ class StorageBootstrapHandlerTests(NeoUnitTestBase):
class StorageAnswerHandlerTests(NeoUnitTestBase): class StorageAnswerHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock() self.app = Mock()
self.app.local_var = Mock() self.app.local_var = Mock()
self.handler = StorageAnswersHandler(self.app) self.handler = StorageAnswersHandler(self.app)
......
...@@ -76,6 +76,7 @@ class ClientTests(NEOFunctionalTest): ...@@ -76,6 +76,7 @@ class ClientTests(NEOFunctionalTest):
def tearDown(self): def tearDown(self):
if self.neo is not None: if self.neo is not None:
self.neo.stop() self.neo.stop()
NEOFunctionalTest.tearDown(self)
def __setup(self): def __setup(self):
# start cluster # start cluster
......
...@@ -30,6 +30,7 @@ class ClusterTests(NEOFunctionalTest): ...@@ -30,6 +30,7 @@ class ClusterTests(NEOFunctionalTest):
def tearDown(self): def tearDown(self):
if self.neo is not None: if self.neo is not None:
self.neo.stop() self.neo.stop()
NEOFunctionalTest.tearDown(self)
def testClusterBreaks(self): def testClusterBreaks(self):
self.neo = NEOCluster(['test_neo1'], self.neo = NEOCluster(['test_neo1'],
......
...@@ -35,6 +35,7 @@ class MasterTests(NEOFunctionalTest): ...@@ -35,6 +35,7 @@ class MasterTests(NEOFunctionalTest):
def tearDown(self): def tearDown(self):
self.neo.stop() self.neo.stop()
NEOFunctionalTest.tearDown(self)
def testStoppingSecondaryMaster(self): def testStoppingSecondaryMaster(self):
# Wait for masters to stabilize # Wait for masters to stabilize
......
...@@ -39,6 +39,7 @@ class StorageTests(NEOFunctionalTest): ...@@ -39,6 +39,7 @@ class StorageTests(NEOFunctionalTest):
def tearDown(self): def tearDown(self):
if self.neo is not None: if self.neo is not None:
self.neo.stop() self.neo.stop()
NEOFunctionalTest.tearDown(self)
def queryCount(self, db, query): def queryCount(self, db, query):
db.query(query) db.query(query)
......
...@@ -26,6 +26,7 @@ from neo.master.app import Application ...@@ -26,6 +26,7 @@ from neo.master.app import Application
class MasterClientHandlerTests(NeoUnitTestBase): class MasterClientHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration(master_number=1, replicas=1) config = self.getMasterConfiguration(master_number=1, replicas=1)
self.app = Application(config) self.app = Application(config)
......
...@@ -34,6 +34,7 @@ def _addPacket(self, packet): ...@@ -34,6 +34,7 @@ def _addPacket(self, packet):
class MasterClientElectionTests(NeoUnitTestBase): class MasterClientElectionTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration(master_number=1) config = self.getMasterConfiguration(master_number=1)
self.app = Application(config) self.app = Application(config)
...@@ -192,6 +193,7 @@ class MasterClientElectionTests(NeoUnitTestBase): ...@@ -192,6 +193,7 @@ class MasterClientElectionTests(NeoUnitTestBase):
class MasterServerElectionTests(NeoUnitTestBase): class MasterServerElectionTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration(master_number=1) config = self.getMasterConfiguration(master_number=1)
self.app = Application(config) self.app = Application(config)
......
...@@ -24,6 +24,7 @@ from neo.util import p64, u64 ...@@ -24,6 +24,7 @@ from neo.util import p64, u64
class MasterAppTests(NeoUnitTestBase): class MasterAppTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration() config = self.getMasterConfiguration()
self.app = Application(config) self.app = Application(config)
......
...@@ -25,6 +25,7 @@ from neo.master.app import Application ...@@ -25,6 +25,7 @@ from neo.master.app import Application
class MasterRecoveryTests(NeoUnitTestBase): class MasterRecoveryTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration() config = self.getMasterConfiguration()
self.app = Application(config) self.app = Application(config)
......
...@@ -28,6 +28,7 @@ from neo.exception import OperationFailure ...@@ -28,6 +28,7 @@ from neo.exception import OperationFailure
class MasterStorageHandlerTests(NeoUnitTestBase): class MasterStorageHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration(master_number=1, replicas=1) config = self.getMasterConfiguration(master_number=1, replicas=1)
self.app = Application(config) self.app = Application(config)
......
...@@ -26,6 +26,7 @@ from neo.master.app import Application ...@@ -26,6 +26,7 @@ from neo.master.app import Application
class MasterVerificationTests(NeoUnitTestBase): class MasterVerificationTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
# create an application object # create an application object
config = self.getMasterConfiguration() config = self.getMasterConfiguration()
self.app = Application(config) self.app = Application(config)
......
...@@ -36,6 +36,7 @@ class StorageClientHandlerTests(NeoUnitTestBase): ...@@ -36,6 +36,7 @@ class StorageClientHandlerTests(NeoUnitTestBase):
self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs) self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs)
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -26,6 +26,7 @@ from neo.storage.handlers.identification import IdentificationHandler ...@@ -26,6 +26,7 @@ from neo.storage.handlers.identification import IdentificationHandler
class StorageIdentificationHandlerTests(NeoUnitTestBase): class StorageIdentificationHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
self.app = Application(config) self.app = Application(config)
self.app.name = 'NEO' self.app.name = 'NEO'
......
...@@ -27,6 +27,7 @@ from neo.exception import PrimaryFailure ...@@ -27,6 +27,7 @@ from neo.exception import PrimaryFailure
class StorageInitializationHandlerTests(NeoUnitTestBase): class StorageInitializationHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -35,6 +35,7 @@ class StorageMasterHandlerTests(NeoUnitTestBase): ...@@ -35,6 +35,7 @@ class StorageMasterHandlerTests(NeoUnitTestBase):
self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs) self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs)
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -27,6 +27,7 @@ from neo.util import dump ...@@ -27,6 +27,7 @@ from neo.util import dump
class StorageAppTests(NeoUnitTestBase): class StorageAppTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -34,6 +34,7 @@ class StorageStorageHandlerTests(NeoUnitTestBase): ...@@ -34,6 +34,7 @@ class StorageStorageHandlerTests(NeoUnitTestBase):
self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs) self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs)
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -30,6 +30,7 @@ NEO_SQL_USER = 'test' ...@@ -30,6 +30,7 @@ NEO_SQL_USER = 'test'
class StorageMySQSLdbTests(NeoUnitTestBase): class StorageMySQSLdbTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1, prefix=NEO_SQL_DATABASE[:-1]) self.prepareDatabase(number=1, prefix=NEO_SQL_DATABASE[:-1])
# db manager # db manager
database = '%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE) database = '%s@%s' % (NEO_SQL_USER, NEO_SQL_DATABASE)
...@@ -39,6 +40,7 @@ class StorageMySQSLdbTests(NeoUnitTestBase): ...@@ -39,6 +40,7 @@ class StorageMySQSLdbTests(NeoUnitTestBase):
def tearDown(self): def tearDown(self):
self.db.close() self.db.close()
NeoUnitTestBase.tearDown(self)
def checkCalledQuery(self, query=None, call=0): def checkCalledQuery(self, query=None, call=0):
self.assertTrue(len(self.db.conn.mockGetNamedCalls('query')) > call) self.assertTrue(len(self.db.conn.mockGetNamedCalls('query')) > call)
......
...@@ -82,6 +82,7 @@ class TransactionTests(NeoUnitTestBase): ...@@ -82,6 +82,7 @@ class TransactionTests(NeoUnitTestBase):
class TransactionManagerTests(NeoUnitTestBase): class TransactionManagerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock() self.app = Mock()
# no history # no history
self.app.dm = Mock({'getObjectHistory': []}) self.app.dm = Mock({'getObjectHistory': []})
......
...@@ -29,6 +29,7 @@ from neo.util import p64, u64 ...@@ -29,6 +29,7 @@ from neo.util import p64, u64
class StorageVerificationHandlerTests(NeoUnitTestBase): class StorageVerificationHandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration(master_number=1) config = self.getStorageConfiguration(master_number=1)
......
...@@ -25,6 +25,7 @@ from neo.protocol import NodeTypes ...@@ -25,6 +25,7 @@ from neo.protocol import NodeTypes
class BootstrapManagerTests(NeoUnitTestBase): class BootstrapManagerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.prepareDatabase(number=1) self.prepareDatabase(number=1)
# create an application object # create an application object
config = self.getStorageConfiguration() config = self.getStorageConfiguration()
......
...@@ -32,6 +32,7 @@ from neo.locking import Queue ...@@ -32,6 +32,7 @@ from neo.locking import Queue
class ConnectionTests(NeoUnitTestBase): class ConnectionTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.app = Mock({'__repr__': 'Fake App'}) self.app = Mock({'__repr__': 'Fake App'})
self.em = Mock({'__repr__': 'Fake Em'}) self.em = Mock({'__repr__': 'Fake Em'})
self.handler = Mock({'__repr__': 'Fake Handler'}) self.handler = Mock({'__repr__': 'Fake Handler'})
...@@ -834,6 +835,7 @@ class MTConnectionTests(ConnectionTests): ...@@ -834,6 +835,7 @@ class MTConnectionTests(ConnectionTests):
class HandlerSwitcherTests(NeoUnitTestBase): class HandlerSwitcherTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self._handler = handler = Mock({ self._handler = handler = Mock({
'__repr__': 'initial handler', '__repr__': 'initial handler',
}) })
...@@ -1087,6 +1089,7 @@ class HandlerSwitcherTests(NeoUnitTestBase): ...@@ -1087,6 +1089,7 @@ class HandlerSwitcherTests(NeoUnitTestBase):
class TestTimeout(NeoUnitTestBase): class TestTimeout(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.current = time() self.current = time()
self.timeout = Timeout() self.timeout = Timeout()
self._updateAt(0) self._updateAt(0)
......
...@@ -25,6 +25,7 @@ from neo.protocol import PacketMalformedError, UnexpectedPacketError, \ ...@@ -25,6 +25,7 @@ from neo.protocol import PacketMalformedError, UnexpectedPacketError, \
class HandlerTests(NeoUnitTestBase): class HandlerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
app = Mock() app = Mock()
self.handler = EventHandler(app) self.handler = EventHandler(app)
self.fake_type = 'FAKE_PACKET_TYPE' self.fake_type = 'FAKE_PACKET_TYPE'
......
...@@ -27,6 +27,7 @@ from time import time ...@@ -27,6 +27,7 @@ from time import time
class NodesTests(NeoUnitTestBase): class NodesTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.manager = Mock() self.manager = Mock()
def _updatedByAddress(self, node, index=0): def _updatedByAddress(self, node, index=0):
...@@ -125,6 +126,7 @@ class NodesTests(NeoUnitTestBase): ...@@ -125,6 +126,7 @@ class NodesTests(NeoUnitTestBase):
class NodeManagerTests(NeoUnitTestBase): class NodeManagerTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.manager = NodeManager() self.manager = NodeManager()
def _addStorage(self): def _addStorage(self):
......
...@@ -24,6 +24,7 @@ from neo.tests import NeoUnitTestBase ...@@ -24,6 +24,7 @@ from neo.tests import NeoUnitTestBase
class ProtocolTests(NeoUnitTestBase): class ProtocolTests(NeoUnitTestBase):
def setUp(self): def setUp(self):
NeoUnitTestBase.setUp(self)
self.ltid = None self.ltid = None
def getNextTID(self): def getNextTID(self):
......
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