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