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

Unify test case names, remove unused test code, inherit from NeoTestBase,

improve readability of the test report.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@629 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 6f205fb7
from neo.client.tests.testClientApp import ClientApplicationTest
from neo.client.tests.testClientHandler import ClientHandlerTest
from neo.client.tests.testConnectionPool import ConnectionPoolTest
from neo.client.tests.testDispatcher import DispatcherTest
from neo.client.tests.testClientApp import ClientApplicationTests
from neo.client.tests.testClientHandler import ClientHandlerTests
from neo.client.tests.testConnectionPool import ConnectionPoolTests
from neo.client.tests.testDispatcher import DispatcherTests
__all__ = [
'ClientApplicationTest',
'ClientHandlerTest',
'ConnectionPoolTest',
'DispatcherTest',
'ClientApplicationTests',
'ClientHandlerTests',
'ConnectionPoolTests',
'DispatcherTests',
]
......@@ -52,7 +52,7 @@ def _waitMessage(self, conn=None, msg_id=None, handler=None):
raise NotImplementedError
class ClientApplicationTest(NeoTestBase):
class ClientApplicationTests(NeoTestBase):
def setUp(self):
# apply monkey patches
......
......@@ -36,24 +36,7 @@ from neo.util import dump
MARKER = []
class BaseClientHandlerTest(NeoTestBase):
def setUp(self):
dispatcher = Mock({'getQueue': queue, 'connectToPrimaryMasterNode': None})
self.handler = BaseClientHandler(dispatcher)
def getConnection(self, uuid=None, port=10010, next_id=None, ip='127.0.0.1'):
if uuid is None:
uuid = self.getNewUUID()
return Mock({'_addPacket': None,
'getUUID': uuid,
'getAddress': (ip, port),
'getNextId': next_id,
'lock': None,
'unlock': None})
class ClientHandlerTest(NeoTestBase):
class ClientHandlerTests(NeoTestBase):
def setUp(self):
# Silence all log messages
......
......@@ -19,25 +19,19 @@ import unittest
from mock import Mock, ReturnValues
from neo.protocol import INVALID_UUID
from neo.tests.base import NeoTestBase
from neo.client.app import ConnectionPool
import os
class ConnectionPoolTest(unittest.TestCase):
def getUUID(self):
uuid = INVALID_UUID
while uuid == INVALID_UUID:
uuid = os.urandom(16)
self.uuid = uuid
return uuid
class ConnectionPoolTests(NeoTestBase):
def test_removeConnection(self):
app = None
pool = ConnectionPool(app)
test_node_uuid = self.getUUID()
test_node_uuid = self.getNewUUID()
other_node_uuid = test_node_uuid
while other_node_uuid == test_node_uuid:
other_node_uuid = self.getUUID()
other_node_uuid = self.getNewUUID()
test_node = Mock({'getUUID': test_node_uuid})
other_node = Mock({'getUUID': other_node_uuid})
# Test sanity check
......
......@@ -19,7 +19,7 @@ import unittest
from neo.client.dispatcher import Dispatcher
class DispatcherTest(unittest.TestCase):
class DispatcherTests(unittest.TestCase):
def test_register(self):
dispatcher = Dispatcher()
......
from neo.tests.testConfig import testConfigurationManager
from neo.tests.testConnection import testConnection
from neo.tests.testEvent import testEvent
from neo.tests.testHandler import HandlerDecoratorsTest, HandlerTest
from neo.tests.testNodes import testNodes
from neo.tests.testPT import testPartitionTable
from neo.tests.testProtocol import testProtocol
from neo.tests.testConfig import ConfigurationManagerTests
from neo.tests.testConnection import ConnectionTests
from neo.tests.testEvent import EventTests
from neo.tests.testHandler import HandlerDecoratorsTests, HandlerTests
from neo.tests.testNodes import NodesTests
from neo.tests.testPT import PartitionTableTests
from neo.tests.testProtocol import ProtocolTests
__all__ = [
'testConfigurationManager',
'testConnection',
'testEvent',
'HandlerDecoratorsTest',
'HandlerTest',
'testNodes',
'testPartitionTable',
'testProtocol',
'ConfigurationManagerTests',
'ConnectionTests',
'EventTests',
'HandlerDecoratorsTests',
'HandlerTests',
'NodesTests',
'PartitionTableTests',
'ProtocolTests',
]
......@@ -23,7 +23,7 @@ from neo.config import ConfigurationManager
from tempfile import mkstemp
class testConfigurationManager(unittest.TestCase):
class ConfigurationManagerTests(unittest.TestCase):
def setUp(self):
pass
......
......@@ -38,7 +38,7 @@ def getNewUUID():
uuid = os.urandom(16)
return uuid
class testConnection(unittest.TestCase):
class ConnectionTests(unittest.TestCase):
def setUp(self):
pass
......
......@@ -22,7 +22,7 @@ from neo.epoll import Epoll
from neo.event import EpollEventManager, IdleEvent
from neo.protocol import Packet, PING
class testEvent(NeoTestBase):
class EventTests(NeoTestBase):
def setUp(self):
pass
......
......@@ -26,14 +26,14 @@ from neo.protocol import UnexpectedPacketError, MASTER_NODE_TYPE, \
from neo.protocol import PacketMalformedError, UnexpectedPacketError, \
BrokenNodeDisallowedError, NotReadyError, ProtocolError
class HandlerDecoratorsTest(NeoTestBase):
class HandlerDecoratorsTests(NeoTestBase):
class FakeApp(object):
nm = None
def setUp(self):
self.handler_called = False
self.app = HandlerDecoratorsTest.FakeApp()
self.app = HandlerDecoratorsTests.FakeApp()
def fakeHandler(self, conn, packet):
self.handler_called = True
......@@ -141,7 +141,7 @@ class HandlerDecoratorsTest(NeoTestBase):
self.checkHandlerCalled(handler)
class HandlerTest(NeoTestBase):
class HandlerTests(NeoTestBase):
def setUp(self):
self.handler = EventHandler()
......
......@@ -22,7 +22,7 @@ from neo.protocol import RUNNING_STATE, TEMPORARILY_DOWN_STATE, DOWN_STATE, BROK
from neo.node import Node, MasterNode, StorageNode, ClientNode, NodeManager
from time import time
class testNodes(unittest.TestCase):
class NodesTests(unittest.TestCase):
def setUp(self):
pass
......
......@@ -24,7 +24,7 @@ from neo.pt import Cell, PartitionTable
from neo.node import StorageNode
from neo.tests.base import NeoTestBase
class testPartitionTable(NeoTestBase):
class PartitionTableTests(NeoTestBase):
def test_01_Cell(self):
uuid = self.getNewUUID()
......
......@@ -21,7 +21,7 @@ from neo import protocol
from neo.protocol import *
from time import time, gmtime
class testProtocol(unittest.TestCase):
class ProtocolTests(unittest.TestCase):
def setUp(self):
self.ltid = INVALID_TID
......
......@@ -30,7 +30,7 @@ TEST_MODULES = [
]
# configuration
WITH_ZODB_TESTS = True
WITH_ZODB_TESTS = False
SEND_REPORT = True
CONSOLE_LOG = False
ATTACH_LOG = False # for ZODB test, only the client side is logged
......@@ -129,7 +129,8 @@ class NeoTestResult(unittest.TestResult):
s += "-------------------------------+--------+--------+--------+----------\n"
format = "%30s | %3d | %3s | %3s | %6.2fs \n"
for k, v in self.modulesStats.items():
args = (k, v.success, v.errors, v.failures, v.time)
errors, failures = v.errors or '.', v.failures or '.'
args = (k, v.success, errors, failures, v.time)
s += format % args
s += "-------------------------------+--------+--------+--------+----------\n"
errors, failures = len(self.errors) or '.', len(self.failures) or '.'
......
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