X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FTemplatedRequests.robot;h=19310f2d3f0f34801c82c2ea2530ef796a8720c3;hb=59db963c1026a8ac1c91b6f9eb21f072ab207c12;hp=c5c05bec68553ae357ecb158a1362bf0c05e4c8f;hpb=3d722df36f8e922fe79d30afc1516346723474ae;p=integration%2Ftest.git diff --git a/csit/libraries/TemplatedRequests.robot b/csit/libraries/TemplatedRequests.robot index c5c05bec68..19310f2d3f 100644 --- a/csit/libraries/TemplatedRequests.robot +++ b/csit/libraries/TemplatedRequests.robot @@ -110,6 +110,7 @@ Documentation Resource for supporting http Requests based on data stored in ... perhaps explicit ${ACCEPT_JSON} will be better, even if it sends few bytes more? Library Collections Library OperatingSystem +Library String Library RequestsLibrary Library ${CURDIR}/norm_json.py Variables ${CURDIR}/../variables/Variables.py @@ -210,9 +211,9 @@ Post_As_Xml_Templated [Return] ${response_text} Delete_Templated - [Arguments] ${folder} ${mapping}={} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} ${http_timeout}=${EMPTY} + [Arguments] ${folder} ${mapping}={} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} ${http_timeout}=${EMPTY} ${location}=location [Documentation] Resolve URI from folder, issue DELETE request. - ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} + ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=${location} extension=uri mapping=${mapping} ${response_text} = Delete_From_Uri uri=${uri} session=${session} additional_allowed_status_codes=${additional_allowed_status_codes} http_timeout=${http_timeout} [Return] ${response_text} @@ -292,13 +293,24 @@ Resolve_Jmes_Path ${expression} = BuiltIn.Set Variable If ${read_jmes_file} == ${true} ${jmes_expression} ${EMPTY} [Return] ${expression} +Resolve_Volatiles_Path + [Arguments] ${folder} + [Documentation] Reads Volatiles List from file ${folder}${/}volatiles.list if the file exists and + ... returns the Volatiles List. Empty string is returned otherwise. + ${read_volatiles_file} = BuiltIn.Run Keyword And Return Status OperatingSystem.File Should Exist ${folder}${/}volatiles.list + Return From Keyword If ${read_volatiles_file} == ${false} ${EMPTY} + ${volatiles}= OperatingSystem.Get_File ${folder}${/}volatiles.list + ${volatiles_list}= String.Split_String ${volatiles} ${\n} + [Return] ${volatiles_list} + Get_Templated [Arguments] ${folder} ${accept} ${mapping}={} ${session}=default ${normalize_json}=False ${http_timeout}=${EMPTY} [Documentation] Resolve URI from folder, call Get_From_Uri, return response text. ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} ${jmes_expression} = Resolve_Jmes_Path ${folder} + ${volatiles_list}= Resolve_Volatiles_Path ${folder} ${response_text} = Get_From_Uri uri=${uri} accept=${accept} session=${session} normalize_json=${normalize_json} jmes_path=${jmes_expression} - ... http_timeout=${http_timeout} + ... http_timeout=${http_timeout} keys_with_volatiles=${volatiles_list} [Return] ${response_text} Put_Templated @@ -340,6 +352,7 @@ Verify_Response_Templated Get_From_Uri [Arguments] ${uri} ${accept}=${ACCEPT_EMPTY} ${session}=default ${normalize_json}=False ${jmes_path}=${EMPTY} ${http_timeout}=${EMPTY} + ... ${keys_with_volatiles}=${EMPTY} [Documentation] GET data from given URI, check status code and return response text. ... \${accept} is a Python object with headers to use. ... If \${normalize_json}, normalize as JSON text before returning. @@ -349,7 +362,7 @@ Get_From_Uri ... ELSE RequestsLibrary.Get_Request alias=${session} uri=${uri} headers=${accept} timeout=${http_timeout} Check_Status_Code ${response} BuiltIn.Run_Keyword_Unless ${normalize_json} BuiltIn.Return_From_Keyword ${response.text} - ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} + ${text_normalized} = norm_json.normalize_json_text ${response.text} jmes_path=${jmes_path} keys_with_volatiles=${keys_with_volatiles} [Return] ${text_normalized} Put_To_Uri