@@ -546,26 +546,56 @@ def step_exit(data_set):
546546 try :
547547 action_value = ""
548548 msg = ""
549- for row in data_set :
550- if row [0 ] == "step exit" and row [1 ] == "action" :
551- action_value = row [2 ]
552- elif row [0 ].strip ().lower () == "message" :
553- msg = row [2 ]
549+ for left , mid , right in data_set :
550+ if left .lower ().strip () == "step exit" :
551+ action_value = right .strip ().lower ()
552+ elif left .strip ().lower () == "message" :
553+ msg = right
554+
554555 except :
555556 return CommonUtil .Exception_Handler (sys .exc_info ())
556557
557- if (
558- action_value in failed_tag_list
559- ): # Convert user specified pass/fail into standard result
560- if msg :
561- CommonUtil .ExecLog (sModuleInfo , f'{ msg } ' , 3 )
558+ if msg :
559+ CommonUtil .ExecLog (sModuleInfo , msg , 3 if "fail" in action_value else 1 )
560+ if "fail" in action_value :
562561 return "zeuz_failed"
563- elif action_value in skipped_tag_list :
564- return "skipped"
565- elif action_value in passed_tag_list :
566- if msg :
567- CommonUtil .ExecLog (sModuleInfo , f'{ msg } ' , 1 )
562+ elif "pass" in action_value :
563+ return "passed"
564+ else :
565+ CommonUtil .ExecLog (sModuleInfo , "Step Result action has invalid VALUE" , 3 )
566+ return "zeuz_failed"
567+
568+
569+ def testcase_exit (data_set ):
570+ """ Exits a Test Step wtih passed/failed in the standard format, when the user specifies it in the step data """
571+
572+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
573+
574+ try :
575+ action_value = ""
576+ for left , mid , right in data_set :
577+ if left .lower ().strip () == "testcase exit" :
578+ action_value = right .strip ().lower ()
579+ except :
580+ return CommonUtil .Exception_Handler (sys .exc_info ())
581+
582+
583+ if "skip" in action_value :
584+ CommonUtil .testcase_exit = "Skipped"
585+ CommonUtil .ExecLog (sModuleInfo , "The testcase will be force Skipped" , 2 )
586+ return "passed"
587+ elif "fail" in action_value :
588+ CommonUtil .ExecLog (sModuleInfo , "The testcase will be force Failed" , 2 )
589+ CommonUtil .testcase_exit = "Failed"
590+ return "zeuz_failed"
591+ elif "pass" in action_value :
592+ CommonUtil .ExecLog (sModuleInfo , "The testcase will be force Passed" , 2 )
593+ CommonUtil .testcase_exit = "Passed"
568594 return "passed"
595+ elif "block" in action_value :
596+ CommonUtil .ExecLog (sModuleInfo , "The testcase will be force Blocked" , 2 )
597+ CommonUtil .testcase_exit = "Blocked"
598+ return "zeuz_failed"
569599 else :
570600 CommonUtil .ExecLog (sModuleInfo , "Step Result action has invalid VALUE" , 3 )
571601 return "zeuz_failed"
@@ -4608,7 +4638,7 @@ def upload_attachment_to_testcase(data_set):
46084638 CommonUtil .ExecLog (sModuleInfo , "Please insert attachment path " , 3 )
46094639 return "zeuz_failed"
46104640 headers = RequestFormatter .add_api_key_to_headers ({})
4611- res = RequestFormatter .request ("post" ,
4641+ res = RequestFormatter .request ("post" ,
46124642 RequestFormatter .form_uri ("test_case_file_upload/" ),
46134643 files = {"file" : open (var_path , 'rb' )},
46144644 data = {"file_upload_tc" : var_id },
@@ -4706,7 +4736,7 @@ def upload_attachment_to_step(data_set):
47064736 CommonUtil .ExecLog (sModuleInfo , "Please insert attachment path " , 3 )
47074737 return "zeuz_failed"
47084738 headers = RequestFormatter .add_api_key_to_headers ({})
4709- res = RequestFormatter .request ("post" ,
4739+ res = RequestFormatter .request ("post" ,
47104740 RequestFormatter .form_uri ("step_file_upload/" ),
47114741 files = {"file" : open (var_path ,'rb' )},
47124742 data = {"file_upload_step" : var_id , },
@@ -4800,7 +4830,7 @@ def upload_attachment_to_global(data_set):
48004830 return "zeuz_failed"
48014831
48024832 headers = RequestFormatter .add_api_key_to_headers ({})
4803- res = RequestFormatter .request ("post" ,
4833+ res = RequestFormatter .request ("post" ,
48044834 RequestFormatter .form_uri ("global_file_upload/" ),
48054835 files = {"file" : open (var_path ,'rb' )},
48064836 verify = False ,
@@ -5905,7 +5935,7 @@ def data_store_read(data_set):
59055935 headers = RequestFormatter .add_api_key_to_headers ({})
59065936 headers ['headers' ]['content-type' ] = 'application/json'
59075937 headers ['headers' ]['X-API-KEY' ] = ConfigModule .get_config_value ("Authentication" , "api-key" )
5908- res = RequestFormatter .request ("get" ,
5938+ res = RequestFormatter .request ("get" ,
59095939 RequestFormatter .form_uri ('data_store/data_store/custom_operation/' ),
59105940 params = json .dumps (params ),
59115941 verify = False ,
@@ -5938,19 +5968,19 @@ def data_store_get_data(data_set):
59385968 columns = right .strip ()
59395969 if 'get data' in left .lower ().strip ():
59405970 variable_name = right .strip ()
5941-
5971+
59425972 if table_name == None or variable_name == None :
59435973 CommonUtil .ExecLog (sModuleInfo , f"Table name and Variable Name both needs to be provided" , 3 )
59445974 return "zeuz failed"
5945-
5975+
59465976 headers = RequestFormatter .add_api_key_to_headers ({})
59475977 headers ['headers' ]['content-type' ] = 'application/json'
59485978 headers ['headers' ]['X-API-KEY' ] = ConfigModule .get_config_value ("Authentication" , "api-key" )
59495979 params = dict ()
59505980 params ['table' ] = table_name
59515981 if columns :
59525982 params ['columns' ] = columns
5953- res = RequestFormatter .request ("get" ,
5983+ res = RequestFormatter .request ("get" ,
59545984 RequestFormatter .form_uri ('data_store/get_datastore/' ),
59555985 params = params ,
59565986 verify = False ,
@@ -5977,17 +6007,17 @@ def data_store_get_stats(data_set):
59776007 table_name = right .strip ()
59786008 if 'stats' in left .lower ().strip ():
59796009 variable_name = right .strip ()
5980-
6010+
59816011 if table_name == None or variable_name == None :
59826012 CommonUtil .ExecLog (sModuleInfo , f"Table name and Variable Name both needs to be provided" , 3 )
59836013 return "zeuz_failed"
5984-
6014+
59856015 headers = RequestFormatter .add_api_key_to_headers ({})
59866016 headers ['headers' ]['content-type' ] = 'application/json'
59876017 headers ['headers' ]['X-API-KEY' ] = ConfigModule .get_config_value ("Authentication" , "api-key" )
59886018 params = dict ()
59896019 params ['table' ] = table_name
5990- res = RequestFormatter .request ("get" ,
6020+ res = RequestFormatter .request ("get" ,
59916021 RequestFormatter .form_uri ('data_store/get_datastore_stats/' ),
59926022 params = params ,
59936023 verify = False ,
@@ -6191,7 +6221,7 @@ def data_store_insert(data_set):
61916221 headers ['headers' ]['content-type' ] = 'application/json'
61926222 headers ['headers' ]['X-API-KEY' ] = ConfigModule .get_config_value ("Authentication" , "api-key" )
61936223
6194- res = RequestFormatter .request ("post" ,
6224+ res = RequestFormatter .request ("post" ,
61956225 RequestFormatter .form_uri ('data_store/data_store/data_store_list/' ),
61966226 data = json .dumps (data ),
61976227 verify = False ,
@@ -6289,25 +6319,25 @@ def xml_to_json(data_set):
62896319 filepath = Path (CommonUtil .path_parser (filepath ))
62906320 if "xml to json" in left :
62916321 json_var_name = right .strip ()
6292-
6322+
62936323 if None in (filepath ,json_var_name ):
62946324 CommonUtil .ExecLog (sModuleInfo , "Please specify both filename and json variable name" , 3 )
62956325
62966326 if filepath != None and filepath .is_file ():
62976327 try :
62986328 with open (filepath ) as xml_file :
62996329 data_dict = xmltodict .parse (xml_file .read ())
6300- result = sr .Set_Shared_Variables (json_var_name , data_dict )
6330+ result = sr .Set_Shared_Variables (json_var_name , data_dict )
63016331 return result
63026332 except :
63036333 CommonUtil .ExecLog (sModuleInfo , "Couldn't read and convert the xml file" , 3 )
63046334 return "zeuz_failed"
6305-
63066335
6307-
6336+
6337+
63086338 else :
63096339 CommonUtil .ExecLog (sModuleInfo , "Specified file couldn't be found or downloaded from attachment" , 3 )
6310- return "zeuz_failed"
6340+ return "zeuz_failed"
63116341
63126342 except :
63136343 return CommonUtil .Exception_Handler (sys .exc_info ())
@@ -6384,7 +6414,7 @@ def connect_to_S3(data_set):
63846414 credentials_source = right .strip ()
63856415 if "file path" in left :
63866416 cred_file_path = right .strip ()
6387-
6417+
63886418 if credentials_source == "default" :
63896419 try :
63906420 s3_client = boto3 .client ('s3' )
@@ -6438,7 +6468,7 @@ def upload_to_S3(data_set):
64386468 if "s3 resource variable" :
64396469 s3_resource_var = right .strip ()
64406470
6441-
6471+
64426472 if None in (bucket_name , file_name ):
64436473 CommonUtil .ExecLog (sModuleInfo , "Bucket, file and key names should be provided" , 3 )
64446474
@@ -6470,7 +6500,7 @@ def connect_to_bigquery_client(data_set):
64706500 if left .strip ().lower () == 'connect to bigquery client' :
64716501 client_var_name = right .strip ()
64726502
6473-
6503+
64746504 os .environ ['GOOGLE_APPLICATION_CREDENTIALS' ] = cred_path
64756505
64766506 try :
@@ -6489,7 +6519,7 @@ def execute_bigquery_query(data_set):
64896519 output variable | input parameter | output variable name
64906520 execute bigquery query | common action | client variable name
64916521 """
6492-
6522+
64936523 from google .cloud import bigquery
64946524
64956525 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
@@ -6505,7 +6535,7 @@ def execute_bigquery_query(data_set):
65056535 client_var_name = right .strip ()
65066536 if left .strip ().lower () == 'output variable' :
65076537 output_var_name = right .strip ()
6508-
6538+
65096539 if None in (query ,client_var_name ,output_var_name ):
65106540 CommonUtil .ExecLog (sModuleInfo , "Incorrect Dataset" , 3 )
65116541 return "zeuz_failed"
@@ -6527,7 +6557,7 @@ def connect_to_google_service_account(data_set):
65276557 credentials path | input parameter | path to credentails json file
65286558 connect to google service client | common action | client variable name
65296559 """
6530-
6560+
65316561 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
65326562 CommonUtil .ExecLog (sModuleInfo , "Actions involving the Google service account may not function correctly without a virtual environment." , 2 )
65336563 cred_path = None
@@ -6538,7 +6568,7 @@ def connect_to_google_service_account(data_set):
65386568 if left .strip ().lower () == 'connect to google service client' :
65396569 client_var_name = right .strip ()
65406570
6541- try :
6571+ try :
65426572 from google .cloud import storage
65436573 client = storage .Client .from_service_account_json (json_credentials_path = cred_path )
65446574 sr .Set_Shared_Variables (client_var_name , client )
@@ -6552,7 +6582,7 @@ def upload_to_google_storage_bucket(data_set):
65526582 """
65536583 data_set:
65546584 filepath | input parameter | filepath
6555- bucket | input parameter | bucket name
6585+ bucket | input parameter | bucket name
65566586 upload to google storage bucket | common action | client variable name
65576587 """
65586588
@@ -6569,7 +6599,7 @@ def upload_to_google_storage_bucket(data_set):
65696599 client_var_name = right .strip ()
65706600 if left .strip ().lower () == 'bucket' :
65716601 bucket = right .strip ()
6572-
6602+
65736603 if None in (filepath ,client_var_name ,bucket ):
65746604 CommonUtil .ExecLog (sModuleInfo , "Incorrect Dataset" , 3 )
65756605 return "zeuz_failed"
@@ -6583,7 +6613,7 @@ def upload_to_google_storage_bucket(data_set):
65836613 return "passed"
65846614 except :
65856615 return CommonUtil .Exception_Handler (sys .exc_info ())
6586-
6616+
65876617@logger
65886618def text_to_speech (data_set ):
65896619 """
@@ -6611,7 +6641,7 @@ def text_to_speech(data_set):
66116641 language = right .strip ()
66126642 if "accent" in left :
66136643 top_level_domain = right .strip ()
6614-
6644+
66156645 if None in (dialogue_data , speaker , output_filename ):
66166646 CommonUtil .ExecLog (sModuleInfo , "Incorrect dataset" , 3 )
66176647 return "zeuz_failed"
0 commit comments