Commit c335c68f by Julien Muchembled

qa: fix test_getServerAddress (testCMFActivity)

With recent changes in CMFActivity, getServerAddress is now used
when setting up the site, before the ZServer is started, which means:
- getServerAddress memoized a wrong return value;
- the test didn't fail with --load.
1 parent b89e433f
......@@ -2455,15 +2455,8 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(activity_node, current_node)
def test_getServerAddress(self):
ip = port = ''
for k, v in socket_map.items():
if hasattr(v, 'addr'):
type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server':
ip, port = v.addr
break
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname())
host, port = self.startZServer()
ip = socket.gethostbyname(host)
server_address = '%s:%s' % (ip, port)
address = getServerAddress()
self.assertEqual(address, server_address)
......
......@@ -158,6 +158,13 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
t = Thread(target=Lifetime.loop)
t.setDaemon(1)
t.start()
from Products.CMFActivity import ActivityTool
# Reset, in case that getServerAddress was already called,
# in which case, the value was ('', '')
if ActivityTool._server_address:
if ActivityTool.currentNode == ActivityTool._server_address:
ActivityTool.currentNode = None
ActivityTool._server_address = None
return utils._Z2HOST, utils._Z2PORT
def _registerNode(self, distributing, processing):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!