Unverified Commit f780bb17 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: add TCs for missing behaviour in NGSI-LD Nulls

parent 2ad92fad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ repos:
    rev: v6.9.2
    hooks:
      - id: robocop-format
        additional_dependencies: [typing_extensions]
        additional_dependencies: [typing_extensions, click]
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ Test Template Create Entity With Invalid Request Scenarios
001_02_04 EntityWithInvalidType
    [Tags]    e-create    5_6_1
    invalid-type.jsonld    ${ERROR_TYPE_BAD_REQUEST_DATA}
001_02_05 EntityWithNullValueProperty
    [Tags]    e-create    5_6_1    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-value-property.jsonld    ${ERROR_TYPE_BAD_REQUEST_DATA}


*** Keywords ***
+44 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that a Merge Entity operation setting an NGSI-LD Null datasetId returns 400 BadRequestData

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

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Merge Entity With Null Reserved Field Scenarios


*** Variables ***
${entity_payload_filename}=     building-simple-attributes.jsonld


*** Test Cases ***    FILENAME
056_06_01 MergeEntitySettingDatasetIdToNull
    [Tags]    e-merge    5_6_17    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-datasetid-fragment.jsonld


*** Keywords ***
Merge Entity With Null Reserved Field Scenarios
    [Documentation]    Check that a Merge Entity operation setting an NGSI-LD Null datasetId returns 400 BadRequestData
    [Arguments]    ${filename}
    ${response}=    Merge Entity
    ...    entity_id=${entity_id}
    ...    entity_filename=${filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    400    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Set Test Variable    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity    ${entity_id}
+55 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that sub-attributes set to NGSI-LD Null in a Merge Entity operation are removed

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

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Merge Entity Scenarios


*** Variables ***
${entity_payload_filename}=     building-relationship-of-property.jsonld


*** Test Cases ***    FILENAME    EXPECTATION_FILENAME
056_07_01 RemoveUnitCodeFromProperty
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-sub-property-unitcode.jsonld    ngsild-null/building-deleted-unitcode.jsonld
056_07_02 RemoveSubAttributeFromProperty
    [Tags]    e-merge    5_6_17    6_5_3_4    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-sub-property-sub-attribute.jsonld    ngsild-null/building-deleted-sub-attribute.jsonld


*** Keywords ***
Merge Entity Scenarios
    [Documentation]    Check that sub-attributes set to NGSI-LD Null in a Merge Entity operation are removed
    [Arguments]    ${filename}    ${expectation_filename}
    ${response}=    Merge Entity
    ...    entity_id=${entity_id}
    ...    entity_filename=${filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}
    Check Response Body Is Empty    ${response}

    ${response1}=    Retrieve Entity
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Response Body Containing Entity element
    ...    expectation_filename=${expectation_filename}
    ...    entity_id=${entity_id}
    ...    response_body=${response1.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Set Test Variable    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity    ${entity_id}
+55 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that LanguageProperty entries can be merged and removed via NGSI-LD Null

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

Test Setup          Setup Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Merge Entity Scenarios


*** Variables ***
${entity_payload_filename}=     building-language-property.jsonld


*** Test Cases ***    FILENAME    EXPECTATION_FILENAME
056_08_01 RemoveLanguageMapProperty
    [Tags]    e-merge    5_6_17    6_5_3_4    4_5_18    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-languagemap-none.jsonld    building-no-attributes.jsonld
056_08_02 MergeLanguageMapPropertyEntries
    [Tags]    e-merge    5_6_17    6_5_3_4    4_5_18    since_v1.6.1
    fragmentEntities/ngsild-null/building-null-languagemap-merge.jsonld    ngsild-null/building-languagemap-merged.jsonld


*** Keywords ***
Merge Entity Scenarios
    [Documentation]    Check that LanguageProperty entries can be merged and removed via NGSI-LD Null
    [Arguments]    ${filename}    ${expectation_filename}
    ${response}=    Merge Entity
    ...    entity_id=${entity_id}
    ...    entity_filename=${filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    204    ${response.status_code}
    Check Response Body Is Empty    ${response}

    ${response1}=    Retrieve Entity
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Response Body Containing Entity element
    ...    expectation_filename=${expectation_filename}
    ...    entity_id=${entity_id}
    ...    response_body=${response1.json()}

Setup Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Set Test Variable    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity    ${entity_id}
Loading