Updated test env documentation
[nonrtric.git] / test / prodstub / app / prodstub.py
index ea8b914..d760440 100644 (file)
@@ -63,7 +63,7 @@ JOB_DATA="/jobdata/<string:producer_id>/<string:job_id>"
 
 STATUS="/status"
 
-#Constsants
+#Constants
 APPL_JSON='application/json'
 UNKNOWN_QUERY_PARAMETERS="Unknown query parameter(s)"
 RETURNING_CONFIGURED_RESP="returning configured response code"
@@ -185,7 +185,7 @@ def index():
 
 # Arm the create callback with a response code
 # Omitting the query parameter switch to response back to the standard 200/201 response
-# URI and parameters (PUT): /arm/create/<producer_id>/<job_id>[?response=<resonsecode>]
+# URI and parameters (PUT): /arm/create/<producer_id>/<job_id>[?response=<repsonsecode>]
 # Setting
 # response: 200 (400 if incorrect query params)
 @app.route(ARM_CREATE_RESPONSE,
@@ -218,7 +218,7 @@ def arm_create(producer_id, job_id):
 
 # Arm the delete callback with a response code
 # Omitting the query parameter switch to response back to the standard 204 response
-# URI and parameters (PUT): /arm/delete/<producer_id>/<job-id>[?response=<resonsecode>]
+# URI and parameters (PUT): /arm/delete/<producer_id>/<job-id>[?response=<responsecode>]
 # response: 200 (400 if incorrect query params)
 @app.route(ARM_DELETE_RESPONSE,
      methods=['PUT'])
@@ -239,7 +239,7 @@ def arm_delete(producer_id, job_id):
 
     job_dict=setup_callback_dict(producer_id, job_id)
 
-    if (arm_response is None): #Reset the response depening if a job exists or not
+    if (arm_response is None): #Reset the response depending if a job exists or not
         if (job_dict['json'] is None):
             job_dict['delete_response']=404
         else:
@@ -251,7 +251,7 @@ def arm_delete(producer_id, job_id):
 
 # Arm the supervision callback with a response code
 # Omitting the query parameter switch to response back to the standard 200 response
-# URI and parameters (PUT): /arm/supervision/<producer_id>[?response=<resonsecode>]
+# URI and parameters (PUT): /arm/supervision/<producer_id>[?response=<responsecode>]
 # response: 200 (400 if incorrect query params)
 @app.route(ARM_SUPERVISION_RESPONSE,
      methods=['PUT'])
@@ -312,6 +312,10 @@ def disarm_type(producer_id, type_id):
 
     if (recursive_search(producer_dict, "ei_job_type",type_id) is True):
         return "TYPE_IN_USE",400
+    elif (recursive_search(producer_dict, "ei_type_identity",type_id) is True):
+        return "TYPE_IN_USE",400
+    elif (recursive_search(producer_dict, "info_type_identity",type_id) is True):
+        return "TYPE_IN_USE",400
 
     type_list=producer_dict['types']
     type_list.remove(type_id)
@@ -339,18 +343,28 @@ def callback_create(producer_id):
     if (producer_dict is None):
         return PRODUCER_OR_JOB_NOT_FOUND,400
     type_list=producer_dict['types']
-    type_id=req_json_dict['ei_type_identity']
-    if (type_id not in type_list):
+
+
+    if 'ei_type_identity' in req_json_dict.keys():
+        type_key_name='ei_type_identity'
+        job_key_name='ei_job_identity'
+    elif 'info_type_identity' in req_json_dict.keys():
+        type_key_name='info_type_identity'
+        job_key_name='info_job_identity'
+    else:
         return TYPE_NOT_FOUND, 400
 
-    job_id=req_json_dict['ei_job_identity']
+    type_id=req_json_dict[type_key_name]
+    job_id=req_json_dict[job_key_name]
+
     job_dict=get_callback_dict(producer_id, job_id)
     if (job_dict is None):
         return PRODUCER_OR_JOB_NOT_FOUND,400
     return_code=0
     return_msg=""
-    if (req_json_dict['ei_job_identity'] == job_id):
+    if (req_json_dict[job_key_name] == job_id):
         print("Create callback received for producer: "+str(producer_id)+" and job: "+str(job_id))
+        print(json.loads(request.data))
         return_code=job_dict['create_response']
         if ((job_dict['create_response'] == 200) or (job_dict['create_response'] == 201)):
             job_dict['json']=req_json_dict