From 346f2695151c2f6fca39a6f79573d30f1641d8eb Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 21 Jan 2016 21:21:12 +0000
Subject: [PATCH] Task #8888: Changed TaskSpecification parameters from
 ({"OtdbID":x}) to (OtdbID=x)

---
 SAS/OTDB_Services/TreeService.py                   |  6 +++---
 SAS/OTDB_Services/test/t_TreeService.py            |  2 +-
 .../Services/src/JobsToSchedule.py                 |  4 ++--
 .../Services/test/tJobsToSchedule.py               | 14 ++++++--------
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/SAS/OTDB_Services/TreeService.py b/SAS/OTDB_Services/TreeService.py
index 33cd9ba53ef..588e5a672ab 100755
--- a/SAS/OTDB_Services/TreeService.py
+++ b/SAS/OTDB_Services/TreeService.py
@@ -239,7 +239,7 @@ class PostgressTaskSpecificationRequest(PostgressMessageHandlerInterface):
     def __init__(self, **kwargs):
         super(PostgressTaskSpecificationRequest, self).__init__(**kwargs)
 
-    def handle_message(self, msg):
+    def handle_message(self, **msg):
         " Connect to the right function"
         return TaskSpecificationRequest(msg, self.connection)
 
@@ -251,7 +251,7 @@ class PostgressStatusUpdateCommand(PostgressMessageHandlerInterface):
     def __init__(self, **kwargs):
         super(PostgressStatusUpdateCommand, self).__init__(**kwargs)
 
-    def handle_message(self, msg):
+    def handle_message(self, **msg):
         " Connect to the right function"
         return StatusUpdateCommand(msg, self.connection)
 
@@ -263,7 +263,7 @@ class PostgressKeyUpdateCommand(PostgressMessageHandlerInterface):
     def __init__(self, **kwargs):
         super(PostgressKeyUpdateCommand, self).__init__(**kwargs)
 
-    def handle_message(self, msg):
+    def handle_message(self, **msg):
         " Connect to the right function"
         return KeyUpdateCommand(msg, self.connection)
 
diff --git a/SAS/OTDB_Services/test/t_TreeService.py b/SAS/OTDB_Services/test/t_TreeService.py
index ff208e81033..dfd601c5816 100644
--- a/SAS/OTDB_Services/test/t_TreeService.py
+++ b/SAS/OTDB_Services/test/t_TreeService.py
@@ -37,7 +37,7 @@ logger = logging.getLogger(__name__)
 
 def do_rpc(rpc_instance, arg_dict):
 #    try:
-    (data, status) = (rpc_instance)(arg_dict)
+    (data, status) = (rpc_instance)(**arg_dict)
     if status != "OK":
         raise Exception("Status returned is %s" % status)
     for key in sorted(data):
diff --git a/SAS/ResourceAssignment/Services/src/JobsToSchedule.py b/SAS/ResourceAssignment/Services/src/JobsToSchedule.py
index 10afe2d791e..c7185662eca 100755
--- a/SAS/ResourceAssignment/Services/src/JobsToSchedule.py
+++ b/SAS/ResourceAssignment/Services/src/JobsToSchedule.py
@@ -178,7 +178,7 @@ class JobsToSchedule(OTDBBusListener):
 
     # Request the parset
     main_obsID  = treeId
-    main_parset,_ = self.parset_rpc( { "OtdbID": main_obsID } )
+    main_parset,_ = self.parset_rpc( OtdbID=main_obsID )
 
     # Construct a dict of all the parsets we retrieved
     parsets = {}
@@ -202,7 +202,7 @@ class JobsToSchedule(OTDBBusListener):
         logger.info("Fetching predecessor %s", obsID)
 
         # Request predecessor parset
-        parsets[obsID],_ = self.parset_rpc( { "OtdbID": obsID } )
+        parsets[obsID],_ = self.parset_rpc( OtdbID=obsID )
 
         # Add the list of predecessors
         request_obsIDs = request_obsIDs.union(predecessors(parsets[obsID]))
diff --git a/SAS/ResourceAssignment/Services/test/tJobsToSchedule.py b/SAS/ResourceAssignment/Services/test/tJobsToSchedule.py
index d3d299ba420..77e43830dd6 100644
--- a/SAS/ResourceAssignment/Services/test/tJobsToSchedule.py
+++ b/SAS/ResourceAssignment/Services/test/tJobsToSchedule.py
@@ -80,23 +80,21 @@ class TestService(unittest.TestCase):
     self.requested_parsets = 0
 
     # setup mock parset service
-    def TaskSpecificationService( input_dict ):
-      obsid = input_dict["OtdbID"]
-
-      if obsid == 1:
+    def TaskSpecificationService( OtdbID ):
+      if OtdbID == 1:
         predecessors = "[2,3]"
-      elif obsid == 2:
+      elif OtdbID == 2:
         predecessors = "[3]"
-      elif obsid == 3:
+      elif OtdbID == 3:
         predecessors = "[]"
       else:
-        raise Exception("Invalid obsID")
+        raise Exception("Invalid OtdbID: %s" % OtdbID)
 
       self.requested_parsets += 1
 
       return {
         "Version.number":                                     "1",
-        PARSET_PREFIX + "Observation.ObsID":                  str(obsid),
+        PARSET_PREFIX + "Observation.ObsID":                  str(OtdbID),
         PARSET_PREFIX + "Observation.Scheduler.predecessors": predecessors,
       }
 
-- 
GitLab