Commit 224bb14b authored by Benedetta Arena's avatar Benedetta Arena
Browse files

fix: update endpoint references and improve entity attribute update tests for...

fix: update endpoint references and improve entity attribute update tests for distributed operations
parent 126694ec
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -26,8 +26,9 @@ D005_01_exc Partial Partial Attribute Update
    [Documentation]    Check that if one request the Context Broker to partially update an attribute whose id matches an exclusive registration, this is updated on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_4

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    ${old_isparked}=    Get Value From Json    ${response.json()}    $.isParked2
    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities   201
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    ${response}=    Partial Update Entity Attributes
@@ -40,24 +41,12 @@ D005_01_exc Partial Partial Attribute Update

    ${stub_count}=    Get Stub Count    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    ${new_isparked}=    Get Value From Json    ${response.json()}    $.isParked2
    Should Be Equal    ${new_isparked}    ${old_isparked}
    Should Not Contain    ${response.json()}    speed


*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${registration_payload}=    Prepare Context Source Registration From File
@@ -65,7 +54,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=exclusive
    ...    endpoint=/broker1
    ...    endpoint=${context_source_url}/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}
    Start Context Source Mock Server
+5 −10
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ D005_01_inc Partial Partial Attribute Update
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    additive-inclusive    4_3_6_2    5_6_4

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${old_isparked}=    Get Value From Json    ${response.json()}    $.isParked2
    ${old_speed}=    Get Value From Json    ${response.json()}    $.speed

    Set Stub Reply    PATCH    /ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}    204
    ${response}=    Partial Update Entity Attributes
@@ -39,16 +39,11 @@ D005_01_inc Partial Partial Attribute Update
    Check Response Status Code    204    ${response.status_code}

    ${stub_count}=    Get Stub Count    PATCH    /ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0

    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    Should Contain    ${response.json()}    isParked2
    Should Contain    ${response.json()}    speed
    Should Be Equal As Integers    ${stub_count}    1

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${new_speed}=    Get Value From Json    ${response.json()}    $.speed
    Should Not Be Equal    ${old_speed}    ${new_speed}

*** Keywords ***
Create Entity And Registration On The Context Broker And Start Context Source Mock Server
+2 −9
Original line number Diff line number Diff line
@@ -38,15 +38,9 @@ D005_01_red Partial Partial Attribute Update

    ${stub_count}=    Get Stub Count    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed

    ${stub_count}=    Get Stub Count    PATCH    /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/${attribute_id}
    Should Be True    ${stub_count} > 0
    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    speed


*** Keywords ***
@@ -61,7 +55,7 @@ Setup Entity Id And Registration And Start Context Source Mock Server
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=redirect
    ...    endpoint=/broker1
    ...    endpoint=${context_source_url}/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

@@ -72,7 +66,7 @@ Setup Entity Id And Registration And Start Context Source Mock Server
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    mode=redirect
    ...    endpoint=/broker2
    ...    endpoint=${context_source_url}/broker2
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}
    Start Context Source Mock Server
@@ -80,5 +74,4 @@ Setup Entity Id And Registration And Start Context Source Mock Server
Delete Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id2}
    Delete Entity    ${entity_id}
    Stop Context Source Mock Server