Commit fba82972 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: add tests for LanguageProperty properties

parent 0134d819
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can retrieve an entity using Language Filter

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

Suite Setup         Create Initial Entity
Suite Teardown      Delete Created Entity
Test Template       Retrieve Entity With Language Filter


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:
${filename}=                building-language-property-sample.jsonld


*** Test Cases ***    LANGUAGE_FILTER    OPTIONS    EXPECTATION_FILENAME
018_07_01 Retrieve an entity using a specific natural language
    fr    ${EMPTY}    building-language-property-fr-filter.jsonld
018_07_02 Retrieve an entity using multiple natural languages with no ranked preference
    fr-CH,fr    ${EMPTY}    building-language-property-fr-filter.jsonld
018_07_03 Retrieve an entity with any supported language
    *    ${EMPTY}    building-language-property-any-language-filter.jsonld
018_07_04 Retrieve an entity using multiple natural languages with ranked preferences
    fr-CH,fr;q=0.9,en;q=0.8,*;q=0.5    ${EMPTY}    building-language-property-fr-filter.jsonld
018_07_05 Retrieve an entity using a specific natural language with simplified representation
    fr    keyValues    building-language-property-fr-filter-simplified.jsonld
018_07_06 Retrieve an entity with any supported language with simplified representation
    *    keyValues    building-language-property-any-language-filter-simplified.jsonld


*** Keywords ***
Retrieve Entity With Language Filter
    [Documentation]    Check that you can retrieve an entity using Language Filter
    [Tags]    e-retrieve    5_7_1    4_15
    [Arguments]    ${language_filter}    ${options}    ${expectation_filename}
    ${response}=    Query Entity
    ...    id=${entity_id}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    context=${ngsild_test_suite_context}
    ...    options=${options}
    ...    lang=${language_filter}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Entity element
    ...    ${expectation_filename}
    ...    ${entity_id}
    ...    ${response.json()}
    ...    ${True}

Create Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}

Delete Created Entity
    Delete Entity by Id    ${entity_id}
+48 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can retrieve the temporal evolution of an entity with a LanguageProperty property

Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/TemporalContextInformationProvision.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Create Temporal Entity
Suite Teardown      Delete Initial Temporal Entity
Test Template       Retrieve Temporal Entity


*** Variables ***
${vehicule_id_prefix}=      urn:ngsi-ld:Vehicle:
${vehicle_payload_file}=    vehicle-language-property-temporal-representation-sample.jsonld


*** Test Cases ***    REPRESENTATION    EXPECTATION_FILENAME
020_12_01 Retrieve the normalized temporal representation of an entity with a LanguageProperty property
    [Tags]    te-retrieve    5_7_3    4_5_7    4_5_18
    ${EMPTY}    vehicle-language-property-normalized-temporal-representation-expectation.jsonld
020_12_02 Retrieve the simplified temporal representation of an entity with a LanguageProperty property
    [Tags]    te-retrieve    5_7_3    4_5_9    4_5_18
    temporalValues    vehicle-language-property-simplified-temporal-representation-expectation.jsonld


*** Keywords ***
Retrieve Temporal Entity
    [Documentation]    Check that you can retrieve the temporal evolution of an entity with a LanguageProperty property
    [Arguments]    ${representation}    ${expectation_filename}
    ${response}=    Retrieve Temporal Representation Of Entity
    ...    temporal_entity_representation_id=${temporal_entity_representation_id}
    ...    options=${representation}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing EntityTemporal element
    ...    ${expectation_filename}
    ...    ${temporal_entity_representation_id}
    ...    ${response.json()}

Create Temporal Entity
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicule_id_prefix}
    Create Temporal Representation Of Entity    ${vehicle_payload_file}    ${temporal_entity_representation_id}
    Set Suite Variable    ${temporal_entity_representation_id}

Delete Initial Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
001_01_04 EntityWithLocationAttribute
    [Tags]    e-create    5_6_1
    building-location-attribute-sample.jsonld    application/ld+json
001_01_05 EntityWithLanguageProperty
    [Tags]    e-create    5_6_1    4_5_18
    building-language-property-sample.jsonld    application/ld+json


*** Keywords ***
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ ${filename}= vehicle-speed-two-datasetid-sample.jsonld
    204    vehicle-new-attribute-fragment.jsonld    vehicle-speed-appended-expectation.jsonld
010_01_02 Append entity attributes with different datasetid
    204    vehicle-speed-different-datasetid-fragment.jsonld    vehicle-speed-different-datasetid-expectation.jsonld
010_01_03 Append a LanguageProperty property
    [Tags]    ea-append    5_6_3    4_5_18
    204    vehicle-new-language-property-fragment.jsonld    vehicle-language-property-appended-expectation.jsonld


*** Keywords ***
+54 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can perform a partial update on a LanguageProperty property

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

Test Setup          Initiate Test Case
Test Teardown       Delete Initial Entities
Test Template       Update Attributes


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Building:
${filename}=                building-language-property-sub-property-sample.jsonld
${status_code}=             204


*** Test Cases ***    FRAGMENT_FILENAME    ATTRIBUTE_ID    EXPECTATION_FILENAME
012_04_01 Check that you can partially update a LanguageProperty property
    building-language-property-fragment.jsonld    street    building-language-property-update-expectation.jsonld


*** Keywords ***
Update Attributes
    [Documentation]    Check that you can perform a partial update on a LanguageProperty property
    [Tags]    ea-partial-update    5_6_4    4_5_18
    [Arguments]    ${fragment_filename}    ${attribute_id}    ${expectation_filename}
    ${response}=    Partial Update Entity Attributes
    ...    entityId=${entity_id}
    ...    attributeId=${attribute_id}
    ...    fragment_filename=${fragment_filename}
    ...    content_type=${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    ${status_code}    ${response.status_code}
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${response1}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ${ignored_attributes}=    Create List    @context
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response1.json()}    ${ignored_attributes}

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

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