From: Peter Gubka Date: Fri, 3 Mar 2017 10:36:08 +0000 (+0100) Subject: Rework Check_Status_Code to check the code with explicitly specified codes X-Git-Tag: release/boron-sr3~111 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a7ef470d121fe5db31a7d94597e49b235fd4db03;p=integration%2Ftest.git Rework Check_Status_Code to check the code with explicitly specified codes Change-Id: I49a7f5970464f149b8acc9b606bf9a73b3136224 Signed-off-by: Peter Gubka --- diff --git a/csit/libraries/TemplatedRequests.robot b/csit/libraries/TemplatedRequests.robot index 5eebc429cc..c3763abf04 100644 --- a/csit/libraries/TemplatedRequests.robot +++ b/csit/libraries/TemplatedRequests.robot @@ -115,7 +115,8 @@ Variables ${CURDIR}/../variables/Variables.py # TODO: Make the following list more narrow when streams without Bug 2594 fix (up to beryllium) are no longer used. @{ALLOWED_STATUS_CODES} ${200} ${201} ${204} # List of integers, not strings. Used by both PUT and DELETE (if the resource should have been present). @{DATA_VALIDATION_ERROR} ${500} -@{ALLOWED_DELETE_STATUS_CODES} ${200} ${201} ${204} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. +@{DELETED_STATUS_CODE} ${404} # List of integers, not strings. Used by DELETE if the resource may be not present. +@{NO_STATUS_CODES} @{KEYS_WITH_BITS} op # the default list with keys to be sorted when norm_json libray is used # TODO: Add option for delete to require 404. @@ -183,10 +184,10 @@ Post_As_Xml_Templated [Return] ${response_text} Delete_Templated - [Arguments] ${folder} ${mapping}={} ${session}=default ${allow_404}=False + [Arguments] ${folder} ${mapping}={} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} [Documentation] Resolve URI from folder, issue DELETE request. ${uri} = Resolve_Text_From_Template_Folder folder=${folder} base_name=location extension=uri mapping=${mapping} - ${response_text} = Delete_From_Uri uri=${uri} session=${session} allow_404=${allow_404} + ${response_text} = Delete_From_Uri uri=${uri} session=${session} additional_allowed_status_codes=${additional_allowed_status_codes} [Return] ${response_text} Verify_Response_As_Json_Templated @@ -246,11 +247,11 @@ Post_As_Xml_To_Uri [Return] ${response_text} Delete_From_Uri - [Arguments] ${uri} ${session}=default ${allow_404}=False + [Arguments] ${uri} ${session}=default ${additional_allowed_status_codes}=${NO_STATUS_CODES} [Documentation] DELETE resource at URI, check status_code and return response text.. BuiltIn.Log ${uri} ${response} = RequestsLibrary.Delete_Request alias=${session} uri=${uri} - Check_Status_Code ${response} allow_404=${allow_404} + Check_Status_Code ${response} additional_allowed_status_codes=${additional_allowed_status_codes} [Return] ${response.text} Get_Templated @@ -339,13 +340,14 @@ Post_To_Uri [Return] ${text_normalized} Check_Status_Code - [Arguments] ${response} ${allow_404}=False + [Arguments] ${response} ${additional_allowed_status_codes}=${NO_STATUS_CODES} ${explicit_status_codes}=${NO_STATUS_CODES} [Documentation] Log response text, check status_code is one of allowed ones. # TODO: Remove overlap with keywords from Utils.robot BuiltIn.Log ${response.text} BuiltIn.Log ${response.status_code} - Run_Keyword_If ${allow_404} BuiltIn.Should_Contain ${ALLOWED_DELETE_STATUS_CODES} ${response.status_code} - ... ELSE BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${response.status_code} + BuiltIn.Run_Keyword_And_Return_If """${explicit_status_codes}""" != """${NO_STATUS_CODES}""" Collections.List_Should_Contain_Value ${explicit_status_codes} ${response.status_code} + ${final_allowd_list} = Collections.Combine_Lists ${ALLOWED_STATUS_CODES} ${additional_allowed_status_codes} + Collections.List_Should_Contain_Value ${final_allowd_list} ${response.status_code} Join_Two_Headers [Arguments] ${first} ${second} diff --git a/csit/suites/netconf/notifications/notifications_basic.robot b/csit/suites/netconf/notifications/notifications_basic.robot index 63ea61d26c..ebb3bbe4d8 100644 --- a/csit/suites/netconf/notifications/notifications_basic.robot +++ b/csit/suites/netconf/notifications/notifications_basic.robot @@ -57,7 +57,7 @@ Clean_Config [Documentation] Make sure config inventory is empty. [Tags] critical BuiltIn.Log ${CONFIG_NODES_API} - TemplatedRequests.Delete_From_Uri uri=${CONFIG_NODES_API} allow_404=True + TemplatedRequests.Delete_From_Uri uri=${CONFIG_NODES_API} additional_allowed_status_codes=${DELETED_STATUS_CODE} # TODO: Rework also other test cases to use TemplatedRequests. Create_Subscribtion