Commit 375ae74a authored by Benedetta Arena's avatar Benedetta Arena
Browse files

fix: update test to improve entity handling

parent b42a88c9
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -16,16 +16,18 @@ Test Teardown Delete Registrations And Stop Context Source Mock Server
*** Variables ***
${first_entity_payload_filename}     vehicle-simple-attributes.jsonld
${second_entity_payload_filename}    vehicle-simple-attributes-second-different.jsonld
${brandname_payload_filename}        vehicle-brandname-fragment.jsonld
${third_entity_payload_filename}     vehicle-simple-attributes-second.json
${brandname_payload_filename}        vehicle-brandname-complete-fragment.jsonld
${entity_pattern}                    urn:ngsi-ld:Vehicle:*
${registration_payload_file_path}    csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

*** Test Cases ***
D018_02_01 Check Post Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Documentation]    Verify that the request contains the POST Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities    201
    ${response}=    Create Entity    ${second_entity_payload_filename}    ${entity_id}
    ${response}=    Create Entity    ${second_entity_payload_filename}    ${entity_id2}
    Check Response Status Code    201    ${response.status_code}

    Wait For Request
@@ -34,14 +36,14 @@ D018_02_01 Check Post Via Header Forwarding To Context Source
    Dictionary Should Contain Key    ${payload}    Via

D018_02_02 Check Update Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Documentation]    Verify that the request contains the PATCH Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    Set Stub Reply    PATCH    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/    204
    ${response}=    Update Entity Attributes
    ...    ${entity_id}
    ...    ${brandname_payload_filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}

    Wait For Request
@@ -50,7 +52,7 @@ D018_02_02 Check Update Via Header Forwarding To Context Source
    Dictionary Should Contain Key    ${payload}    Via

D018_02_03 Check Delete Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Documentation]    Verify that the request contains the DELETE Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    204
@@ -63,14 +65,15 @@ D018_02_03 Check Delete Via Header Forwarding To Context Source
    Dictionary Should Contain Key    ${payload}    Via

D018_02_04 Check Put Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Documentation]    Verify that the request contains the PUT Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    PUT    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Replace Entity
    ...    ${entity_id}
    ...    ${second_entity_payload_filename}
    ...    ${CONTENT_TYPE_LD_JSON}
    ...    ${third_entity_payload_filename}
    ...    ${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}

    Wait For Request
@@ -79,7 +82,7 @@ D018_02_04 Check Put Via Header Forwarding To Context Source
    Dictionary Should Contain Key    ${payload}    Via

D018_02_05 Check Get Via Header Forwarding To Context Source
    [Documentation]    Verify that the request contains the Via header when forwarding operations to the Context Source
    [Documentation]    Verify that the request contains the GET Via header when forwarding operations to the Context Source
    [Tags]    since_v1.8.1    dist-ops    4_3_3    cf_06    additive-inclusive    5_6_6    6_3_18

    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200
@@ -95,6 +98,8 @@ D018_02_05 Check Get Via Header Forwarding To Context Source
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}
    ${entity_id2}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id2}
    ${response}=    Create Entity    ${first_entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

@@ -103,7 +108,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    entity_id_pattern=${entity_pattern}
    ...    mode=inclusive
    ...    endpoint=/broker1
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
@@ -113,5 +118,6 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo

Delete Registrations And Stop Context Source Mock Server
    Delete Entity    ${entity_id}
    Delete Entity    ${entity_id2}
    Delete Context Source Registration    ${registration_id}
    Stop Context Source Mock Server