feat: add new tcs for replace attribute endpoint

Merge request reports

Loading
+5 −2
Changes for TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_01.robot: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -27,14 +27,17 @@ ${expectation_filename} building-locatedAt-and-name-normalized.jsonl
    ${response}=    Replace Entity Selecting Content Type
    ...    entity_id=${entity_id}
    ...    entity_fragment=${entity}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    ...    content_type=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    ${response1}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    options=sysAttrs
    ${ignored_attributes}=    Create List    @context    createdAt    modifiedAt
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${entity_expectation_payload}=    Load Test Sample
    ...    test_sample_file_path=entities/expectations/${expectation_filename}
    ...    test_sample_id=${entity_id}
    Check Updated Resource Set To
    ...    updated_resource=${entity_expectation_payload}
    ...    response_body=${response1.json()}
+2 −1
Changes for TP/NGSI-LD/ContextInformation/Provision/Entities/ReplaceEntity/054_02.robot: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ Replace an existing entity with a faulty ID
    ${response}=    Replace Entity Selecting Content Type
    ...    entity_id=${faulty_entity_id}
    ...    entity_fragment=${entity}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    ...    content_type=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    ${expected_status_code}    ${response.status_code}

Setup Initial Entity
+73 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_01.robot: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Replace Entity Attribute


*** Variables ***
${vehicle_id_prefix}    urn:ngsi-ld:Vehicle:
${entity_filename}      vehicle-speed-multi-instances.jsonld


*** Test Cases ***    ATTRIBUTE_FILE_NAME    EXPECTATION_FILE_NAME
055_01_01 Replace entity attribute
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    vehicle-isParked-attribute.json    vehicle-replace-isParked-attribute.jsonld
055_01_02 Replace entity attribute giving a new attribute type
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    vehicle-isParked-new-type-attribute.json    vehicle-replace-isParked-new-type-attribute.jsonld


*** Keywords ***
Replace Entity Attribute
    [Documentation]    Check that one can replace an existing entity attribute and that its createdAt Temporal Property remains unchanged
    [Arguments]    ${attribute_replacement_filename}    ${expectation_filename}
    ${attribute}=    Load Test Sample
    ...    test_sample_file_path=entities/${attribute_replacement_filename}
    ...    test_sample_id=${entity_id}
    ${response}=    Replace Attribute Selecting Content Type
    ...    entity_id=${entity_id}
    ...    attr_id=isParked
    ...    attribute_fragment=${attribute}
    ...    content_type=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    ${response1}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    options=sysAttrs
    ${ignored_attributes}=    Create List    @context    createdAt    modifiedAt
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    Check Updated Resource Set To
    ...    updated_resource=${entity_expectation_payload}
    ...    response_body=${response1.json()}
    ...    ignored_keys=${ignored_attributes}
    Check JSON Value In Response Body
    ...    json_path_expr=['isParked']['createdAt']
    ...    value_to_check=${createdAt}
    ...    response_body=${response1.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${entity_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    options=sysAttrs
    ${createdAt}=    Set Variable    ${response.json()['isParked']['createdAt']}
    Set Test Variable    ${createdAt}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+73 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_02.robot: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Replace Multi Instance Entity Attribute


*** Variables ***
${vehicle_id_prefix}    urn:ngsi-ld:Vehicle:
${entity_filename}      vehicle-speed-multi-instances.jsonld


*** Test Cases ***    ATTRIBUTE_FILE_NAME    EXPECTATION_FILE_NAME
055_02_01 Replace entity attribute giving no datasetId
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    vehicle-speed-default-instance.json    vehicle-replace-speed-default-instance.jsonld
055_02_02 Replace entity attribute giving a datasetId
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    vehicle-speed-datasetid-instance.json    vehicle-replace-speed-datasetid-instance.jsonld


*** Keywords ***
Replace Multi Instance Entity Attribute
    [Documentation]    Check that one can replace an existing multi-instance entity attribute and that its createdAt Temporal Property remains unchanged
    [Arguments]    ${attribute_replacement_filename}    ${expectation_filename}
    ${attribute}=    Load Test Sample
    ...    test_sample_file_path=entities/${attribute_replacement_filename}
    ...    test_sample_id=${entity_id}
    ${response}=    Replace Attribute Selecting Content Type
    ...    entity_id=${entity_id}
    ...    attr_id=speed
    ...    attribute_fragment=${attribute}
    ...    content_type=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    ${response1}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    options=sysAttrs
    ${ignored_attributes}=    Create List    @context    createdAt    modifiedAt
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    Check Updated Resource Set To
    ...    updated_resource=${entity_expectation_payload}
    ...    response_body=${response1.json()}
    ...    ignored_keys=${ignored_attributes}
    Check JSON Value In Response Body
    ...    json_path_expr=['speed'][0]['createdAt']
    ...    value_to_check=${createdAt}
    ...    response_body=${response1.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${entity_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    options=sysAttrs
    ${createdAt}=    Set Variable    ${response.json()['speed'][0]['createdAt']}
    Set Test Variable    ${createdAt}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+62 −0
Changes for TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/ReplaceEntityAttribute/055_03.robot: 62 added lines, 0 removed lines.
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that the correct error type is returned when replacing an attribute with faulty data

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Replace Entity Attribute With Faulty Data


*** Variables ***
${vehicle_id_prefix}    urn:ngsi-ld:Vehicle:
${entity_filename}      vehicle-speed-multi-instances.jsonld


*** Test Cases ***    ENTITY_ID    ATTR_ID    ATTRIBUTE_FILE_NAME    EXPECTED_STATUS_CODE
055_03_01 Replace entity attribute giving an invalid entity ID
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    invalidUri    isParked    vehicle-isParked-attribute.json    400
055_03_02 Replace entity attribute giving a nonexistent entity ID
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    urn:ngsi-ld:Vehicle:Nonexistent    isParked    vehicle-isParked-attribute.json    404
055_03_03 Replace entity attribute giving an invalid attribute name
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    ${entity_id}    @invalid    vehicle-isParked-attribute.json    400
055_03_04 Replace entity attribute giving a nonexistent attribute name
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    ${entity_id}    brandName    vehicle-isParked-attribute.json    404
055_03_05 Replace entity attribute giving a scope attribute
    [Tags]    ea-replace    5_6_19    6_7_3_3    since_v1.6.1
    ${entity_id}    scope    vehicle-scope-attribute.json    400


*** Keywords ***
Replace Entity Attribute With Faulty Data
    [Documentation]    Check that the correct error type is returned when replacing an attribute with faulty data
    [Arguments]    ${target_entity_id}    ${attr_id}    ${attribute_replacement_filename}    ${expected_status_code}
    ${attribute}=    Load Test Sample
    ...    test_sample_file_path=entities/${attribute_replacement_filename}
    ...    test_sample_id=${entity_id}
    ${response}=    Replace Attribute Selecting Content Type
    ...    entity_id=${target_entity_id}
    ...    attr_id=${attr_id}
    ...    attribute_fragment=${attribute}
    ...    content_type=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    ${expected_status_code}    ${response.status_code}

Setup Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${entity_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
Loading
Loading