From c53d70d440ce3e15d7740695a51c475ff4354ddb Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Fri, 18 Mar 2016 15:34:23 +0100
Subject: [PATCH] erp5.util.testnode: update unit test to take into account
 transfer of slapos instance params

---
 erp5/tests/testERP5TestNode.py      | 16 ++++++++--------
 erp5/util/testnode/NodeTestSuite.py |  1 +
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/erp5/tests/testERP5TestNode.py b/erp5/tests/testERP5TestNode.py
index 3dd08caf1e..cb2238c889 100644
--- a/erp5/tests/testERP5TestNode.py
+++ b/erp5/tests/testERP5TestNode.py
@@ -579,7 +579,7 @@ develop = false
     def patch_getSlaposHateoasUrl(self, *args, **kw):
       return "http://Foo"
     def patch_generateConfiguration(self, *args, **kw):
-      return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\
+      return json.dumps({"configuration_list": [{}], "involved_nodes_computer_guid"\
 : [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \
 "launchable": False, "randomized_path" : "azertyuiop"})
     def patch_isMasterTestnode(self, *args, **kw):
@@ -654,7 +654,6 @@ develop = false
       original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
       original_getSlaposUrl = TaskDistributor.getSlaposUrl
       original_getSlaposHateoasUrl = TaskDistributor.getSlaposHateoasUrl
-      original_generateConfiguration = TaskDistributor.generateConfiguration
       original_isMasterTestnode = TaskDistributor.isMasterTestnode
       original_updateInstanceXML = RunnerClass._updateInstanceXML
       original_isHostingSubscriptionReady = SlapOSMasterCommunicator.isHostingSubscriptionReady
@@ -664,12 +663,13 @@ develop = false
       TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
       TaskDistributor.getSlaposUrl = patch_getSlaposUrl
       TaskDistributor.getSlaposHateoasUrl = patch_getSlaposHateoasUrl
-      TaskDistributor.generateConfiguration = patch_generateConfiguration
       TaskDistributor.isMasterTestnode = patch_isMasterTestnode
       RunnerClass._updateInstanceXML = doNothing
       SlapOSMasterCommunicator.isHostingSubscriptionReady = patch_isHostingSubscriptionReady
       SlapOSMasterCommunicator.isRegisteredHostingSubscription = patch_isRegisteredHostingSubscription
       SlapOSMasterCommunicator.__init__ = doNothing
+    original_generateConfiguration = TaskDistributor.generateConfiguration
+    TaskDistributor.generateConfiguration = patch_generateConfiguration
     original_startTestSuite = TaskDistributor.startTestSuite
     original_subscribeNode = TaskDistributor.subscribeNode
     original_getTestType = TaskDistributor.getTestType
@@ -697,12 +697,12 @@ develop = false
       TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
       TaskDistributor.getSlaposUrl = original_getSlaposUrl
       TaskDistributor.getSlaposHateoasUrl = original_getSlaposHateoasUrl
-      TaskDistributor.generateConfiguration = original_generateConfiguration
       TaskDistributor.isMasterTestnode = original_isMasterTestnode
       RunnerClass._updateInstanceXML = original_updateInstanceXML
       SlapOSMasterCommunicator.isHostingSubscriptionReady = original_isHostingSubscriptionReady
       SlapOSMasterCommunicator.isRegisteredHostingSubscription = original_isRegisteredHostingSubscription
       SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
+    TaskDistributor.generateConfiguration = original_generateConfiguration
     TaskDistributor.startTestSuite = original_startTestSuite
     TaskDistributionTool.createTestResult = original_createTestResult
     TaskDistributionTool.subscribeNode = original_subscribeNode
@@ -763,7 +763,7 @@ develop = false
     def patch_getSlaposHateoasUrl(self, *args, **kw):
       return "http://Foo"
     def patch_generateConfiguration(self, *args, **kw):
-      return json.dumps({"configuration_list": [], "involved_nodes_computer_guid"\
+      return json.dumps({"configuration_list": [{}], "involved_nodes_computer_guid"\
 : [], "error_message": "No error.", "launcher_nodes_computer_guid": [], \
 "launchable": False, "randomized_path" : "azertyuiop"})
     def patch_isMasterTestnode(self, *args, **kw):
@@ -824,7 +824,6 @@ develop = false
       original_getSlaposAccountCertificate = TaskDistributor.getSlaposAccountCertificate
       original_getSlaposUrl = TaskDistributor.getSlaposUrl
       original_getSlaposHateoasUrl = TaskDistributor.getSlaposHateoasUrl
-      original_generateConfiguration = TaskDistributor.generateConfiguration
       original_isMasterTestnode = TaskDistributor.isMasterTestnode
       original_supply = SlapOSControler.supply
       original_request = SlapOSControler.request
@@ -836,7 +835,6 @@ develop = false
       TaskDistributor.getSlaposAccountCertificate = patch_getSlaposAccountCertificate
       TaskDistributor.getSlaposUrl = patch_getSlaposUrl
       TaskDistributor.getSlaposHateoasUrl = patch_getSlaposHateoasUrl
-      TaskDistributor.generateConfiguration = patch_generateConfiguration
       TaskDistributor.isMasterTestnode = patch_isMasterTestnode
       SlapOSControler.supply = doNothing
       SlapOSControler.request = doNothing
@@ -844,9 +842,11 @@ develop = false
       SlapOSMasterCommunicator.isHostingSubscriptionReady = patch_isHostingSubscriptionReady
       SlapOSMasterCommunicator.isRegisteredHostingSubscription = patch_isRegisteredHostingSubscription
       SlapOSMasterCommunicator.__init__ = doNothing
+    original_generateConfiguration = TaskDistributor.generateConfiguration
     original_startTestSuite = TaskDistributor.startTestSuite
     original_subscribeNode = TaskDistributor.subscribeNode
     original_getTestType = TaskDistributor.getTestType
+    TaskDistributor.generateConfiguration = patch_generateConfiguration
     TaskDistributor.startTestSuite = patch_startTestSuite
     TaskDistributor.subscribeNode = doNothing
     TaskDistributor.getTestType = patch_getTestType
@@ -875,7 +875,6 @@ develop = false
       TaskDistributor.getSlaposAccountCertificate = original_getSlaposAccountCertificate
       TaskDistributor.getSlaposUrl = original_getSlaposUrl
       TaskDistributor.getSlaposHateoasUrl = original_getSlaposHateoasUrl
-      TaskDistributor.generateConfiguration = original_generateConfiguration
       TaskDistributor.isMasterTestnode = original_isMasterTestnode
       SlapOSControler.supply =original_supply
       SlapOSControler.request = original_request
@@ -883,6 +882,7 @@ develop = false
       SlapOSMasterCommunicator.isHostingSubscriptionReady = original_isHostingSubscriptionReady
       SlapOSMasterCommunicator.isRegisteredHostingSubscription = original_isRegisteredHostingSubscription
       SlapOSMasterCommunicator.__init__ = original_SlapOSMasterCommunicator__init__
+    TaskDistributor.generateConfiguration = original_generateConfiguration
     TaskDistributor.startTestSuite = original_startTestSuite
     TaskDistributionTool.createTestResult = original_createTestResult
     TaskDistributionTool.subscribeNode = original_subscribeNode
diff --git a/erp5/util/testnode/NodeTestSuite.py b/erp5/util/testnode/NodeTestSuite.py
index f4ff3ac6c6..286b19471b 100644
--- a/erp5/util/testnode/NodeTestSuite.py
+++ b/erp5/util/testnode/NodeTestSuite.py
@@ -65,6 +65,7 @@ class NodeTestSuite(SlapOSInstance):
   def __init__(self, reference):
     super(NodeTestSuite, self).__init__()
     self.reference = reference
+    self.cluster_configuration = {}
 
   def edit(self, **kw):
     super(NodeTestSuite, self).edit(**kw)
-- 
2.30.9