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