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

feat: add TCs for Vocab properties

parent 01839849
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can retrieve the temporal evolution of an entity with a VocabProperty 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 ***
${vehicle_payload_file}=    vehicle-vocab-property-temporal-representation.jsonld


*** Test Cases ***    REPRESENTATION    EXPECTATION_FILENAME
020_16_01 Retrieve the normalized temporal representation of an entity with a VocabProperty property
    [Tags]    te-retrieve    5_7_3    4_5_7    4_5_24    since_v1.7.1
    ${EMPTY}    vehicle-vocab-property-temporal-representation.json
020_16_02 Retrieve the simplified temporal representation of an entity with a VocabProperty property
    [Tags]    te-retrieve    5_7_3    4_5_9    4_5_24    since_v1.7.1
    temporalValues    vehicle-vocab-property-simplified-temporal-representation.json


*** Keywords ***
Retrieve Temporal Entity
    [Documentation]    Check that one can retrieve the temporal evolution of an entity with a VocabProperty 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 Vehicle Entity Id
    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}
+44 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can create an entity with a VocabProperty 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


*** Test Cases ***    FILENAME    CONTENT_TYPE
001_15_01 EntityWithVocabPropertyAsString
    [Tags]    e-create    5_6_1    4_5_20    since_v1.7.1
    building-vocab-property-string.jsonld    application/ld+json
001_15_02 EntityWithVocabPropertyAsArray
    [Tags]    e-create    5_6_1    4_5_20    since_v1.7.1
    building-vocab-property-array.jsonld    application/ld+json


*** Keywords ***
Create Entity Scenarios
    [Documentation]    Check that you can create an entity with a VocabProperty property
    [Arguments]    ${filename}    ${content_type}
    ${entity_id}=    Generate Random Building Entity Id
    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}
+49 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can append a VocabProperty 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 To Entity


*** Variables ***
${filename}=    vehicle-minimal.jsonld


*** Test Cases ***    STATUS_CODE    FRAGMENT_FILENAME    EXPECTATION_FILENAME
010_11_01 Append a VocabProperty property
    [Tags]    ea-append    5_6_3    4_5_20    since_v1.7.1
    204    vehicle-new-vocab-property-fragment.jsonld    vehicle-vocab-property-appended.jsonld


*** Keywords ***
Append Attributes To Entity
    [Documentation]    Check that you can append a VocabProperty 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
    ...    updated_resource=${entity_expectation_payload}
    ...    response_body=${response1.json()}

Create Initial Entity
    ${entity_id}=    Generate Random Vehicle Entity Id
    ${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}
+46 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can delete a VocabProperty property from 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


*** Variables ***
${filename}=                building-vocab-property-string.jsonld
${expectation_filename}=    building-minimal.json


*** Test Cases ***
013_07_01 Delete a VocabProperty property from an entity
    [Documentation]    Check that you can delete a VocabProperty property from an entity
    [Tags]    ea-delete    5_6_5    4_5_20    since_v1.7.1
    ${response}=    Delete Entity Attributes
    ...    ${entity_id}
    ...    vocabProperty
    ...    ${EMPTY}
    ...    false
    Check Response Status Code    204    ${response.status_code}
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${response}=    Retrieve Entity by Id
    ...    ${entity_id}
    ...    accept=${CONTENT_TYPE_JSON}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Building Entity Id
    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 Entity
    Delete Entity by Id    ${entity_id}
+53 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can perform a partial update on a VocabProperty 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 ***
${filename}=        building-vocab-property-sub-property.jsonld
${status_code}=     204


*** Test Cases ***    FRAGMENT_FILENAME    ATTRIBUTE_ID    EXPECTATION_FILENAME
012_09_01 Check that you can partially update a VocabProperty property
    [Tags]    ea-partial-update    5_6_4    4_5_20    since_v1.7.1
    building-vocab-property-fragment.jsonld    vocabProperty    building-vocab-property-update.jsonld


*** Keywords ***
Update Attributes
    [Documentation]    Check that you can perform a partial update on a VocabProperty property
    [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 Vehicle Entity Id
    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