Commit 86819c9c authored by Grégory Wisniewski's avatar Grégory Wisniewski

Partial rewrite of Node and NodeManager classes:

* Manager now index per node type and node state
* Use set() instead of list() to ensure node unicity
* Rename 'server' attribute to 'address' for consistency
* Remove 'filter' parameter from clear(), because it's never used.
* Update tests 


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1317 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 053eaa8b
This diff is collapsed.
......@@ -31,19 +31,13 @@ class NodesTests(NeoTestBase):
def setUp(self):
self.manager = Mock()
def _updatedByServer(self, node, index=0):
calls = self.manager.mockGetNamedCalls('unregisterServer')
self.assertEqual(len(calls), index + 1)
self.assertEqual(calls[index].getParam(0), node)
calls = self.manager.mockGetNamedCalls('registerServer')
def _updatedByAddress(self, node, index=0):
calls = self.manager.mockGetNamedCalls('_updateAddress')
self.assertEqual(len(calls), index + 1)
self.assertEqual(calls[index].getParam(0), node)
def _updatedByUUID(self, node, index=0):
calls = self.manager.mockGetNamedCalls('unregisterUUID')
self.assertEqual(len(calls), index + 1)
self.assertEqual(calls[index].getParam(0), node)
calls = self.manager.mockGetNamedCalls('registerUUID')
calls = self.manager.mockGetNamedCalls('_updateUUID')
self.assertEqual(len(calls), index + 1)
self.assertEqual(calls[index].getParam(0), node)
......@@ -74,7 +68,7 @@ class NodesTests(NeoTestBase):
self.assertEqual(node.getServer(), None)
server = ('127.0.0.1', 10000)
node.setServer(server)
self._updatedByServer(node)
self._updatedByAddress(node)
def testUUID(self):
""" As for Server but UUID """
......@@ -238,26 +232,6 @@ class NodeManagerTests(NeoTestBase):
self.checkNodes([])
self.checkClients([])
def testFilteredClear(self):
""" Check the clear filter works well """
manager = self.manager
manager.add(self.master)
manager.add(self.storage)
manager.add(self.client)
self.checkNodes([self.master, self.storage, self.client])
drop_clients = lambda node: isinstance(node, ClientNode)
manager.clear(filter=drop_clients)
self.checkNodes([self.master, self.storage])
self.checkClients([])
drop_masters = lambda node: isinstance(node, MasterNode)
manager.clear(filter=drop_masters)
self.checkNodes([self.storage])
self.checkMasters([])
drop_storage = lambda node: node is self.storage
manager.clear(filter=drop_storage)
self.checkNodes([])
self.checkStorages([])
def testUpdate(self):
""" Check manager content update """
# set up four nodes
......
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