Commit 5cbd5e66 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'feature/add-language-property-tests' into 'develop'

feat: add tests for LanguageProperty properties

See merge request !128
parents a7e95248 f9c9fa41
Loading
Loading
Loading
Loading
+67 −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
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    fr    ${EMPTY}    building-language-property-fr-filter.jsonld
018_07_02 Retrieve an entity using multiple natural languages with no ranked preference
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    fr-CH,fr    ${EMPTY}    building-language-property-fr-filter.jsonld
018_07_03 Retrieve an entity with any supported language
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    *    ${EMPTY}    building-language-property-any-language-filter.jsonld
018_07_04 Retrieve an entity using multiple natural languages with ranked preferences
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    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
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    fr    keyValues    building-language-property-fr-filter-simplified.jsonld
018_07_06 Retrieve an entity with any supported language with simplified representation
    [Tags]    e-retrieve    5_7_1    4_15    since_v1.4.1
    *    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
    [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    since_v1.4.1
    ${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    since_v1.4.1
    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}
+45 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can create an entity with 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 Teardown       Delete Initial Entity
Test Template       Create Entity Scenarios


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:


*** Test Cases ***    FILENAME    CONTENT_TYPE
001_10_01 EntityWithLanguageProperty
    [Tags]    e-create    5_6_1    4_5_18    since_v1.4.1
    building-language-property-sample.jsonld    application/ld+json


*** Keywords ***
Create Entity Scenarios
    [Documentation]    Check that you can create an entity with a LanguageProperty property
    [Arguments]    ${filename}    ${content_type}
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${content_type}
    Check Response Status Code    201    ${response.status_code}
    Check Response Headers Containing URI set to    ${entity_id}    ${response.headers}
    ${created_entity}=    Load Test Sample    entities/${filename}    ${entity_id}
    ${response1}=    Retrieve Entity by Id
    ...    id=${entity_id}
    ...    accept=${content_type}
    ...    context=${ngsild_test_suite_context}
    Check Created Resource Set To
    ...    created_resource=${created_entity}
    ...    response_body=${response1.json()}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+2 −1
Original line number Diff line number Diff line
@@ -18,15 +18,16 @@ ${filename}= vehicle-speed-two-datasetid-sample.jsonld

*** Test Cases ***    STATUS_CODE    FRAGMENT_FILENAME    EXPECTATION_FILENAME
010_01_01 Append entity attributes
    [Tags]    ea-append    5_6_3
    204    vehicle-new-attribute-fragment.jsonld    vehicle-speed-appended-expectation.jsonld
010_01_02 Append entity attributes with different datasetid
    [Tags]    ea-append    5_6_3
    204    vehicle-speed-different-datasetid-fragment.jsonld    vehicle-speed-different-datasetid-expectation.jsonld


*** Keywords ***
Append Attributes Without Params
    [Documentation]    Check that you can append entity attributes
    [Tags]    ea-append    5_6_3
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_filename}
    ${response}=    Append Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    ${status_code}    ${response.status_code}
+48 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can append a LanguageProperty property to an entity

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

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity
Test Template       Append Attributes Without Params


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${filename}=                vehicle-speed-two-datasetid-sample.jsonld


*** Test Cases ***    STATUS_CODE    FRAGMENT_FILENAME    EXPECTATION_FILENAME
010_06_01 Append a LanguageProperty property
    [Tags]    ea-append    5_6_3    4_5_18    since_v1.4.1
    204    vehicle-new-language-property-fragment.jsonld    vehicle-language-property-appended-expectation.jsonld


*** Keywords ***
Append Attributes Without Params
    [Documentation]    Check that you can append a LanguageProperty property to an entity
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_filename}
    ${response}=    Append Entity Attributes    ${entity_id}    ${fragment_filename}    ${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}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response1.json()}

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

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