creating Normalize_Jsons_With_Bits_And_Compare to TemplatedRequests 65/46865/4
authorPeter Gubka <pgubka@cisco.com>
Thu, 13 Oct 2016 08:02:44 +0000 (10:02 +0200)
committerVratko Polák <vrpolak@cisco.com>
Fri, 14 Oct 2016 10:56:19 +0000 (10:56 +0000)
implementing https://trello.com/c/SavMOS52/332-int-test-create-a-new-kw-in-templatedrequests-for-comparison

Change-Id: I7ecd79b2c5e2763067d2fc3c1138e3b3b5268fe7
Signed-off-by: Peter Gubka <pgubka@cisco.com>
csit/libraries/TemplatedRequests.robot
csit/suites/bgpcep/bgpflowspec/010_bgp_flowspec.robot
csit/suites/bgpcep/bgpfunct/010_bgp_functional_l3vpn.robot
csit/suites/bgpcep/bgpfunct/020_bgp_functional_multipath.robot
csit/suites/bgpcep/bgpfunct/030_bgp_functional_evpn.robot
csit/suites/bgpcep/bgpfunct/040_bgp_functional_route_ref.robot

index 008a666b4f55f99519a72cf678e3d847040cc366..4b87ee54117dff845a9dcf9b2444c32c7180f992 100644 (file)
@@ -115,6 +115,7 @@ 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).
 @{ALLOWED_DELETE_STATUS_CODES}    ${200}    ${201}    ${204}    ${404}    # List of integers, not strings. Used by DELETE if the resource may be not present.
+@{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.
 
 *** Keywords ***
@@ -401,3 +402,10 @@ Normalize_Jsons_And_Compare
     # Should_Be_Equal shall print nice diff-style line comparison.
     BuiltIn.Should_Be_Equal    ${expected_normalized}    ${actual_normalized}
     # TODO: Add garbage collection? Check whether the temporary data accumulates.
+
+Normalize_Jsons_With_Bits_And_Compare
+    [Arguments]    ${expected_raw}    ${actual_raw}    ${keys_with_bits}=${KEYS_WITH_BITS}
+    [Documentation]    Use norm_json to normalize both JSON arguments, call Should_Be_Equal.
+    ${expected_normalized} =    norm_json.normalize_json_text    ${expected_raw}    keys_with_bits=${keys_with_bits}
+    ${actual_normalized} =    norm_json.normalize_json_text    ${actual_raw}    keys_with_bits=${keys_with_bits}
+    BuiltIn.Should_Be_Equal    ${expected_normalized}    ${actual_normalized}
index 41b68dd633005847322a37fc5fdba053fab6d243..328f5ae6eb9cc329d0f066c50b849155042a7828 100644 (file)
@@ -16,7 +16,7 @@ Resource          ${CURDIR}/../../../libraries/Utils.robot
 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
 Resource          ${CURDIR}/../../../libraries/CompareStream.robot
-Library           ${CURDIR}/../../../libraries/norm_json.py
+Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
 
 *** Variables ***
 ${HOLDTIME}       180
@@ -124,13 +124,8 @@ Verify Flowspec Data
     ${keys_with_bits}=    BuiltIn.Create_List
     CompareStream.Run_Keyword_If_At_Most    boron    Collections.Append_To_List    ${keys_with_bits}    op
     ${expected_rsp}=    Get Expected Response From File    ${exprspfile}
-    ${expected_json}=    norm_json.Normalize Json Text    ${expected_rsp}    keys_with_bits=${keys_with_bits}
     ${rsp}=    RequestsLibrary.Get Request    session    ${FLOWSPEC_URL}
-    BuiltIn.Log    ${rsp.content}
-    ${received_json}=    norm_json.Normalize Json Text    ${rsp.content}    keys_with_bits=${keys_with_bits}
-    BuiltIn.Log    ${received_json}
-    BuiltIn.Log    ${expected_json}
-    BuiltIn.Should Be Equal    ${received_json}    ${expected_json}
+    TemplatedRequests.Normalize_Jsons_With_Bits_And_Compare    ${expected_rsp}    ${rsp.content}    keys_with_bits=${keys_with_bits}
 
 Get Expected Response From File
     [Arguments]    ${exprspfile}
index d9edaf4cf5dd66d2d501fbfeb61e4fdcb90604b4..3a80c8ea0045448041a510312c2f0abac705d0b3 100644 (file)
@@ -21,7 +21,6 @@ Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Library           ${CURDIR}/../../../libraries/norm_json.py
 Library           ${CURDIR}/../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
 
 *** Variables ***
@@ -174,23 +173,14 @@ Verify_Tool_Received_Update
     ${exp_update}=    Get_Expected_Response_From_File    ${exp_update_fn}
     ${rcv_update_dict}=    BgpRpcClient.exa_get_update_message    msg_only=${True}
     ${rcv_update}=    BuiltIn.Evaluate    json.dumps(${rcv_update_dict})    modules=json
-    ${received_json}=    norm_json.Normalize_Json_Text    ${rcv_update}
-    ${expected_json}=    norm_json.Normalize_Json_Text    ${exp_update}
-    BuiltIn.Log    ${received_json}
-    BuiltIn.Log    ${expected_json}
-    BuiltIn.Should_Be_Equal    ${received_json}    ${expected_json}
+    TemplatedRequests.Normalize_Jsons_And_Compare    ${exp_update}    ${rcv_update}
 
 Verify_Reported_Data
     [Arguments]    ${url}    ${exprspfile}
     [Documentation]    Verifies expected response
     ${expected_rsp}=    Get_Expected_Response_From_File    ${exprspfile}
-    ${expected_json}=    norm_json.Normalize_Json_Text    ${expected_rsp}
     ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${url}
-    BuiltIn.Log    ${rsp.content}
-    ${received_json}=    norm_json.Normalize_Json_Text    ${rsp.content}
-    BuiltIn.Log    ${received_json}
-    BuiltIn.Log    ${expected_json}
-    BuiltIn.Should_Be_Equal    ${received_json}    ${expected_json}
+    TemplatedRequests.Normalize_Jsons_And_Compare    ${expected_rsp}    ${rsp.content}
 
 Get_Expected_Response_From_File
     [Arguments]    ${exprspfile}
index dbeb3f9b9673e2b973d6faa6539389e0090cfe1d..5dec69af11fa1559dbddbad577d6517f8b2f0936 100644 (file)
@@ -18,7 +18,6 @@ Variables         ${CURDIR}/../../../variables/Variables.py
 Resource          ${CURDIR}/../../../libraries/Utils.robot
 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
-Library           ${CURDIR}/../../../libraries/norm_json.py
 Library           ${CURDIR}/../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
index 656577650d9647e8e26066bcbdb2a1c04d3a8464..49d04dfebb0358fdeab8effbe351489966ba0223 100644 (file)
@@ -21,7 +21,6 @@ Variables         ${CURDIR}/../../../variables/Variables.py
 Resource          ${CURDIR}/../../../libraries/Utils.robot
 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
-Library           ${CURDIR}/../../../libraries/norm_json.py
 Library           ${CURDIR}/../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
@@ -416,9 +415,4 @@ Loc_Rib_Presnece
     [Arguments]    ${exp_content}
     [Documentation]    Verifies if loc-rib contains expected data
     ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${LOC_RIB_URL}    headers=${HEADERS}
-    Log    ${rsp.content}
-    ${received_json}=    norm_json.Normalize_Json_Text    ${rsp.content}
-    BuiltIn.Log    ${received_json}
-    ${expected_json}=    norm_json.Normalize_Json_Text    ${exp_content}
-    BuiltIn.Log    ${expected_json}
-    BuiltIn.Should_Be_Equal    ${received_json}    ${expected_json}
+    TemplatedRequests.Normalize_Jsons_And_Compare    ${exp_content}    ${rsp.content}
index 15bfaf33011f81f7e8cebed91bf80d63c920930b..8ccab4586021c689025cd04b7973b04060ccd338 100644 (file)
@@ -24,7 +24,6 @@ Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Library           ${CURDIR}/../../../libraries/norm_json.py
 Library           ${CURDIR}/../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
 
 *** Variables ***