Commit 4be57a80 authored by poujol's avatar poujol
Browse files

Merge branch 'fix/using-time-proporty-for-test-instead-of-sysattrs' into 'develop'

fix(016_01): using timeproperty parameter instead of sysAttrs options

See merge request cim/ngsi-ld-test-suite!74
parents cc8277f2 621c6098
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ ${expectation_filename}= vehicle-temporal-representation-delete-speed-instanc
    Set Suite Variable    ${temporal_entity_representation_id}
    ${response}=    Create Or Update Temporal Representation Of Entity Selecting Content Type    ${temporal_entity_representation_id}    ${filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response['status']}
    ${response}=    Get Temporal Representation Of Entity    ${temporal_entity_representation_id}    ${CONTENT_TYPE_LD_JSON}    sysAttrs    ${ngsild_test_suite_context}
    Retrieve Temporal Representation Of Entity    ${temporal_entity_representation_id}    context=${ngsild_test_suite_context}    accept=${CONTENT_TYPE_LD_JSON}
    ${instanceId}=    Set Variable    ${response['body']['speed'][0]['instanceId']}
    ${response}=    Delete Attribute Instance From Temporal Entity    ${temporal_entity_representation_id}    ${attributeId}    ${instanceId}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    Check Response Status Code    204    ${response['status']}
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ Resource ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Suite Setup       Create Id
Test Template     Partially Update Temporal Entity
Test Template     Delete Attribute Instance

*** Variable ***
${vehicle_id_prefix}=    urn:ngsi-ld:Vehicle:
@@ -22,7 +22,7 @@ ${status_code}= 404
                      ${temporal_entity_representation_id}    speed           urn:ngsi-ld:01234567890123456789

*** Keywords ***
Partially Update Temporal Entity
Delete Attribute Instance
    [Arguments]    ${temporal_entity_id}    ${attributeId}    ${instanceId}
    [Documentation]    Check that you cannot delete an attribute instance in temporal representation of an entity if the entity/attribute/instance id is not found
    [Tags]    tea-instance-delete    5_6_15
+39 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation     Check that you can partially update an attribute instance of a temporal representation of an entity
Documentation     Check that you can modify an attribute instance in temporal representation of an entity
Resource          ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
@@ -7,34 +7,33 @@ Resource ${EXECDIR}/resources/JsonUtils.resource
*** Variable ***
${vehicle_id_prefix}=    urn:ngsi-ld:Vehicle:
${filename}=      vehicle-temporal-representation-sample.jsonld
${fragment_filename}=    vehicle-temporal-instanceid-update-fragment.jsonld
${expectation_filename}=    vehicle-temporal-representation-partial-update-attribute-expectation.jsonld
${fragment_filename}=    vehicle-temporal-modify-attribute-instance-fragment.jsonld
${expectation_filename}=    vehicle-temporal-representation-modify-attribute-instance-expectation.jsonld
${attributeId}=    speed

*** Test Cases ***
016_01_Partially update an attribute instance of a temporal representation of an entity
016_01_Modify attribute instance in temporal representation of an entity
    [Documentation]    Check that you can partially update an attribute instance of a temporal representation of an entity
    [Tags]    tea-partial-update    5_6_14
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Suite Variable    ${temporal_entity_representation_id}

    ${response}=    Create Or Update Temporal Representation Of Entity Selecting Content Type    ${temporal_entity_representation_id}    ${filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response['status']}
    ${response}=    Get Temporal Representation Of Entity    ${temporal_entity_representation_id}    ${CONTENT_TYPE_LD_JSON}    sysAttrs    ${ngsild_test_suite_context}
    ${createdAt_before_update}=    Set Variable    ${response['body']['speed'][0]['createdAt']}
    ${modifiedAt_before_update}=    Set Variable    ${response['body']['speed'][0]['modifiedAt']}
    ${instanceId}=    Set Variable    ${response['body']['speed'][0]['instanceId']}
    ${response}=    Partial Update Attribute From Temporal Entity    ${temporal_entity_representation_id}    ${attributeId}    ${instanceId}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}

    Retrieve Temporal Representation Of Entity    ${temporal_entity_representation_id}    context=${ngsild_test_suite_context}    accept=${CONTENT_TYPE_LD_JSON}
    ${instanceId_before_update}=    Set Variable    ${response['body']['speed'][0]['instanceId']}

    ${response}=    Modify Attribute Instance From Temporal Entity    ${temporal_entity_representation_id}    ${attributeId}    ${instanceId_before_update}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    Check Response Status Code    204    ${response['status']}
    ${response}=    Get Temporal Representation Of Entity    ${temporal_entity_representation_id}    ${CONTENT_TYPE_LD_JSON}    sysAttrs
    ${createdAt_after_update}=    Set Variable    ${response['body']['speed'][0]['createdAt']}
    ${modifiedAt_after_update}=    Set Variable    ${response['body']['speed'][0]['modifiedAt']}
    Should Be Equal As Strings    ${createdAt_before_update}    ${modifiedAt_before_update}
    Should Be Equal As Strings    ${createdAt_before_update}    ${createdAt_after_update}
    ${modifiedAt_before_update_date}=    Convert Date    ${modifiedAt_before_update}    epoch
    ${modifiedAt_after_update_date}=    Convert Date    ${modifiedAt_after_update}    epoch
    Should Be True    ${modifiedAt_before_update_date}<${modifiedAt_after_update_date}

    ${temporal_entity_expectation_payload}=    Load Test Sample    temporalEntities/expectations/${expectation_filename}    ${temporal_entity_representation_id}
    Retrieve Temporal Representation Of Entity    ${temporal_entity_representation_id}    context=${ngsild_test_suite_context}    accept=${CONTENT_TYPE_LD_JSON}
    ${ignored_attributes}=    Create List    instanceId    @context
    ${instanceId_after_update}=    Set Variable    ${response['body']['speed'][0]['instanceId']}

    Should Be Equal As Strings      ${instanceId_before_update}      ${instanceId_after_update}

    ${temporal_entity_expectation_payload}=    Load Test Sample    temporalEntities/expectations/${expectation_filename}    ${temporal_entity_representation_id}
    ${ignored_attributes}=    Create List    instanceId    @context     modifiedAt
    Check Updated Resource Set To    ${temporal_entity_expectation_payload}    ${ignored_attributes}
    [Teardown]    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+16 −13
Original line number Diff line number Diff line
*** Settings ***
Documentation     Check that you cannot partially update an attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
Documentation     Check that you cannot modify an attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
Resource          ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Suite Setup       Create Id
Test Template     Partially Update Temporal Entity
Suite Teardown    Delete Temporal Entity
Test Template     Modify Attribute Instance Temporal Entity

*** Variable ***
${vehicle_id_prefix}=    urn:ngsi-ld:Vehicle:
${filename}=      vehicle-temporal-representation-sample.jsonld
${fragment_filename}=    vehicle-temporal-instanceid-update-fragment.jsonld
${fragment_filename}=    vehicle-temporal-modify-attribute-instance-fragment.jsonld
${status_code}=    400

*** Test Cases ***    TEMPORAL_ENTITY_ID                      ATTRIBUTE_ID    INSTANCE_ID
016_02_01_update an attribute instance in temporal representation of an entity if the entity id is not valid
016_02_01_modify attribute instance in temporal representation of an entity if the entity id is not valid
                      invalidId                               speed           ${valid_instanceId}

016_02_02_update an attribute instance in temporal representation of an entity if the entity id is not present
016_02_02_modify attribute instance in temporal representation of an entity if the entity id is not present
                      ${EMPTY}                                speed           ${valid_instanceId}

016_02_03_update an attribute instance in temporal representation of an entity if the instance id is not valid
016_02_03_modify attribute instance in temporal representation of an entity if the instance id is not valid
                      ${temporal_entity_representation_id}    speed           invalidId

016_02_04_update an attribute instance in temporal representation of an entity if the instance id is not present
016_02_04_modify attribute instance in temporal representation of an entity if the instance id is not present
                      ${temporal_entity_representation_id}    speed           ${EMPTY}

016_02_05_update an attribute instance in temporal representation of an entity if the attribute name is not a valid name
016_02_05_modify attribute instance in temporal representation of an entity if the attribute name is not a valid name
                      ${temporal_entity_representation_id}    invalid(Id      ${valid_instanceId}

016_02_06_update an attribute instance in temporal representation of an entity if the attribute name is not present
016_02_06_modify attribute instance in temporal representation of an entity if the attribute name is not present
                      ${temporal_entity_representation_id}    ${EMPTY}        ${valid_instanceId}

*** Keywords ***
Partially Update Temporal Entity
Modify Attribute Instance Temporal Entity
    [Arguments]    ${temporal_entity_id}    ${attributeId}    ${instanceId}
    [Documentation]    Check that you cannot partially update an attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
    [Documentation]    Check that you cannot partially modify attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
    [Tags]    tea-partial-update    5_6_14
    ${response}=    Partial Update Attribute From Temporal Entity    ${temporal_entity_id}    ${attributeId}    ${instanceId}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    ${response}=    Modify Attribute Instance From Temporal Entity    ${temporal_entity_id}    ${attributeId}    ${instanceId}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    Check Response Status Code    ${status_code}    ${response['status']}
    [Teardown]    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}

Create Id
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
@@ -48,3 +48,6 @@ Create Id
    ${response}=    Get Temporal Representation Of Entity    ${temporal_entity_representation_id}    ${CONTENT_TYPE_LD_JSON}    sysAttrs    ${ngsild_test_suite_context}
    ${valid_instanceId}=    Set Variable    ${response['body']['speed'][0]['instanceId']}
    Set Suite Variable    ${valid_instanceId}

Delete Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
+13 −10
Original line number Diff line number Diff line
*** Settings ***
Documentation     Check that you cannot partially update an attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
Documentation     Check that you cannot modify an attribute instance in temporal representation of an entity if the entityId/attributeId/instanceId is not right
Resource          ${EXECDIR}/resources/ApiUtils.resource
Resource          ${EXECDIR}/resources/AssertionUtils.resource
Resource          ${EXECDIR}/resources/JsonUtils.resource
Suite Setup       Create Id
Test Template     Partially Update Temporal Entity
Suite Teardown    Delete Temporal Entity
Test Template     Modify Attribute Instance Temporal Entity

*** Variable ***
${vehicle_id_prefix}=    urn:ngsi-ld:Vehicle:
${filename}=      vehicle-temporal-representation-sample.jsonld
${fragment_filename}=    vehicle-temporal-instanceid-update-fragment.jsonld
${fragment_filename}=    vehicle-temporal-modify-attribute-instance-fragment.jsonld
${status_code}=    404

*** Test Cases ***    TEMPORAL_ENTITY_ID                      ATTRIBUTE_ID    INSTANCE_ID
016_03_01_update an attribute instance in temporal representation of an entity if the entity with given id is not found
016_03_01_modify attribute instance in temporal representation of an entity if the entity with given id is not found
                      ${unknown_temporal_entity_id}           speed           ${valid_instanceId}

016_03_02_update an attribute instance in temporal representation of an entity if the target attribute is not found
016_03_02_modify attribute instance in temporal representation of an entity if the target attribute is not found
                      ${temporal_entity_representation_id}    speed2          ${valid_instanceId}

016_03_03_update an attribute instance in temporal representation of an entity if the target attribute instance is not found
016_03_03_modify attribute instance in temporal representation of an entity if the target attribute instance is not found
                      ${temporal_entity_representation_id}    speed           urn:ngsi-ld:01234567890123456789

*** Keywords ***
Partially Update Temporal Entity
Modify Attribute Instance Temporal Entity
    [Arguments]    ${temporal_entity_id}    ${attributeId}    ${instanceId}
    [Documentation]    Check that you cannot partially update an attribute instance in temporal representation of an entity if the entity/attribute/instance id is not found
    [Documentation]    Check that you cannot partially modify attribute instance in temporal representation of an entity if the entity/attribute/instance id is not found
    [Tags]    tea-partial-update    5_6_14
    ${response}=    Partial Update Attribute From Temporal Entity    ${temporal_entity_id}    ${attributeId}    ${instanceId}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    ${response}=    Modify Attribute Instance From Temporal Entity    ${temporal_entity_id}    ${attributeId}    ${instanceId}    ${fragment_filename}    ${CONTENT_TYPE_JSON}    ${ngsild_test_suite_context}
    Check Response Status Code    ${status_code}    ${response['status']}
    [Teardown]    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}

Create Id
    ${temporal_entity_representation_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
@@ -41,3 +41,6 @@ Create Id
    ${response}=    Get Temporal Representation Of Entity    ${temporal_entity_representation_id}    ${CONTENT_TYPE_LD_JSON}    sysAttrs    ${ngsild_test_suite_context}
    ${valid_instanceId}=    Set Variable    ${response['body']['speed'][0]['instanceId']}
    Set Suite Variable    ${valid_instanceId}

Delete Temporal Entity
    Delete Temporal Representation Of Entity    ${temporal_entity_representation_id}
Loading