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

feat: extract some tests setup / teardown steps from the core of the TC

parent 887cd07a
Loading
Loading
Loading
Loading
+14 −10
Original line number Original line Diff line number Diff line
@@ -6,7 +6,6 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity
Test Teardown       Delete Initial Entity




@@ -19,6 +18,13 @@ ${filename}= building-simple-attributes-sample.json
001_04_01 Create one entity using a provided Link header with JSON content type and NGSILD context
001_04_01 Create one entity using a provided Link header with JSON content type and NGSILD context
    [Documentation]    Check that the @context is obtained from a Link Header if the Content-Type header is "application/json"
    [Documentation]    Check that the @context is obtained from a Link Header if the Content-Type header is "application/json"
    [Tags]    e-create    6_3_5
    [Tags]    e-create    6_3_5
    ${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_JSON}
    ...    context=${ngsild_test_suite_context}
    ${response}=    Retrieve Entity by Id    id=${entity_id}    context=${ngsild_test_suite_context}
    ${response}=    Retrieve Entity by Id    id=${entity_id}    context=${ngsild_test_suite_context}
    # Attribute should be compacted as we used the same context as provided when creating the entity
    # Attribute should be compacted as we used the same context as provided when creating the entity
    Check Response Body Containing an Attribute set to
    Check Response Body Containing an Attribute set to
@@ -28,15 +34,6 @@ ${filename}= building-simple-attributes-sample.json
001_04_02 Create one entity using a provided Link header with JSON content type and no context
001_04_02 Create one entity using a provided Link header with JSON content type and no context
    [Documentation]    Check that the @context is obtained from a Link Header if the Content-Type header is "application/json"
    [Documentation]    Check that the @context is obtained from a Link Header if the Content-Type header is "application/json"
    [Tags]    e-create    6_3_5
    [Tags]    e-create    6_3_5
    ${response}=    Retrieve Entity by Id    id=${entity_id}
    # Attribute should not be compacted as we did not provide a context containing this term
    Check Response Body Containing an Attribute set to
    ...    expected_attribute_name=https://ngsi-ld-test-suite/context#almostFull
    ...    response_body=${response.json()}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${entity_id}
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ${response}=    Create Entity Selecting Content Type
@@ -44,6 +41,13 @@ Create Initial Entity
    ...    ${entity_id}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_JSON}
    ...    ${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    ...    context=${ngsild_test_suite_context}
    ${response}=    Retrieve Entity by Id    id=${entity_id}
    # Attribute should not be compacted as we did not provide a context containing this term
    Check Response Body Containing an Attribute set to
    ...    expected_attribute_name=https://ngsi-ld-test-suite/context#almostFull
    ...    response_body=${response.json()}



*** Keywords ***
Delete Initial Entity
Delete Initial Entity
    Delete Entity by Id    ${entity_id}
    Delete Entity by Id    ${entity_id}
+14 −7
Original line number Original line Diff line number Diff line
@@ -6,6 +6,8 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


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




@@ -26,12 +28,6 @@ Append Attributes Without Params
    [Documentation]    Check that you can append entity attributes
    [Documentation]    Check that you can append entity attributes
    [Tags]    ea-append    5_6_3
    [Tags]    ea-append    5_6_3
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_filename}
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_filename}
    ${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}
    ${response}=    Append Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    ${response}=    Append Entity Attributes    ${entity_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    ${status_code}    ${response.status_code}
    Check Response Status Code    ${status_code}    ${response.status_code}
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
@@ -40,4 +36,15 @@ Append Attributes Without Params
    ...    context=${ngsild_test_suite_context}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}

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 Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+15 −7
Original line number Original line Diff line number Diff line
@@ -5,6 +5,8 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.re
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


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




@@ -28,16 +30,22 @@ Append Attributes
    [Documentation]    Check that you cannot append entity attributes with invalid/missing id or invalid request body
    [Documentation]    Check that you cannot append entity attributes with invalid/missing id or invalid request body
    [Tags]    ea-append    5_6_3
    [Tags]    ea-append    5_6_3
    [Arguments]    ${entity_invalid_id}
    [Arguments]    ${entity_invalid_id}
    ${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}
    ${response}=    Append Entity Attributes    ${entity_invalid_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    ${response}=    Append Entity Attributes    ${entity_invalid_id}    ${fragment_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    ${status_code}    ${response.status_code}
    Check Response Status Code    ${status_code}    ${response.status_code}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    Check Response Body Containing ProblemDetails Element Containing Type Element set to
    ...    ${response.json()}
    ...    ${response.json()}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    ...    ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response.json()}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}
    [Teardown]    Delete Entity by Id    ${entity_id}

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 Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+14 −7
Original line number Original line Diff line number Diff line
@@ -6,6 +6,8 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.re
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


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




@@ -26,12 +28,6 @@ Append Attributes With Params
    [Documentation]    Check that you can append entity attributes
    [Documentation]    Check that you can append entity attributes
    [Tags]    ea-append    5_6_3
    [Tags]    ea-append    5_6_3
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_response_body}    ${expectation_filename}
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_response_body}    ${expectation_filename}
    ${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}
    ${response}=    Append Entity Attributes With Parameters
    ${response}=    Append Entity Attributes With Parameters
    ...    ${entity_id}
    ...    ${entity_id}
    ...    ${fragment_filename}
    ...    ${fragment_filename}
@@ -52,4 +48,15 @@ Append Attributes With Params
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ${ignored_attributes}=    Create List    @context
    ${ignored_attributes}=    Create List    @context
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}    ${ignored_attributes}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}    ${ignored_attributes}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}

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 Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+17 −7
Original line number Original line Diff line number Diff line
@@ -5,6 +5,9 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.re
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource


Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity



*** Variables ***
*** Variables ***
${vehicle_id_prefix}=               urn:ngsi-ld:Vehicle:
${vehicle_id_prefix}=               urn:ngsi-ld:Vehicle:
@@ -18,12 +21,6 @@ ${invalid_fragment_filename}= invalid-fragment.jsonld
010_05_01 Append entity attributes with invalid entity fragments
010_05_01 Append entity attributes with invalid entity fragments
    [Documentation]    Check that you cannot append entity attributes with invalid entity fragments
    [Documentation]    Check that you cannot append entity attributes with invalid entity fragments
    [Tags]    ea-append    5_6_3
    [Tags]    ea-append    5_6_3
    ${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}
    ${response}=    Append Entity Attributes
    ${response}=    Append Entity Attributes
    ...    ${entity_id}
    ...    ${entity_id}
    ...    ${invalid_fragment_filename}
    ...    ${invalid_fragment_filename}
@@ -31,4 +28,17 @@ ${invalid_fragment_filename}= invalid-fragment.jsonld
    Check Response Status Code    ${status_code}    ${response.status_code}
    Check Response Status Code    ${status_code}    ${response.status_code}
    Check Response Body Type When Using Session Request    ${response.json()}    ${ERROR_TYPE_INVALID_REQUEST}
    Check Response Body Type When Using Session Request    ${response.json()}    ${ERROR_TYPE_INVALID_REQUEST}
    Check Response Body Title When Using Session Request    ${response.json()}
    Check Response Body Title When Using Session Request    ${response.json()}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}


*** Keywords ***
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 Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}