Commit 8755db35 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

refactor: move data setup in a test setup step / remove useless data creation in CB

parent d34f4182
Loading
Loading
Loading
Loading
+19 −26
Original line number Diff line number Diff line
@@ -6,27 +6,21 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity


*** Variables ***
${vehicle_id_prefix}=       urn:ngsi-ld:Vehicle:
${vehicle_filename}=        vehicle-simple-attributes-sample.jsonld
${vehicle_fragment}=        vehicle-brandname-fragment.json
${attribute_id}=            brandName
${subscription_id_prefix}=      urn:ngsi-ld:Subscription:
${subscription_filename}=       subscriptions/subscription-sample.jsonld
${subscription_fragment}=       subscriptions/fragments/subscription-update-sample.json


*** Test Cases ***
044_01_01 Endpoint /entities/{entityId}/attrs/{attrId}
    [Documentation]    Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type
    [Tags]    ea-partial-update    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${response}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Partial Update Entity Attributes
    ...    ${entity_id}
    ...    ${attribute_id}
@@ -34,18 +28,17 @@ ${subscription_fragment}= subscriptions/fragments/subscription-update-samp
    ...    ${CONTENT_TYPE_MERGE_PATCH_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    [Teardown]    Delete Entity by Id    ${entity_id}

044_01_02 Endpoint /subscriptions/{subscriptionId}
    [Documentation]    Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type
    [Tags]    sub-update    6_3_4
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${response}=    Create Subscription    ${subscription_id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}

*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${response}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Update Subscription
    ...    ${subscription_id}
    ...    ${subscription_fragment}
    ...    ${CONTENT_TYPE_MERGE_PATCH_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}
    [Teardown]    Delete Subscription    ${subscription_id}
    Set Test Variable    ${entity_id}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+39 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type

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

Test Setup          Create Initial Subscription
Test Teardown       Delete Initial Subscription


*** Variables ***
${subscription_id_prefix}=      urn:ngsi-ld:Subscription:
${subscription_filename}=       subscriptions/subscription-sample.jsonld
${subscription_fragment}=       subscriptions/fragments/subscription-update-sample.json


*** Test Cases ***
044_02_01 Endpoint /subscriptions/{subscriptionId}
    [Documentation]    Verify that PATCH HTTP requests can be done with "application/merge-patch+json" as Content-Type
    [Tags]    sub-update    6_3_4
    ${response}=    Update Subscription
    ...    ${subscription_id}
    ...    ${subscription_fragment}
    ...    ${CONTENT_TYPE_MERGE_PATCH_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}


*** Keywords ***
Create Initial Subscription
    ${subscription_id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${response}=    Create Subscription    ${subscription_id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    Set Test Variable    ${subscription_id}

Delete Initial Subscription
    Delete Subscription    ${subscription_id}
+0 −9
Original line number Diff line number Diff line
@@ -15,9 +15,7 @@ Resource ${EXECDIR}/resources/JsonUtils.resource
${accept}=                      application/xml
${status_code}=                 406
${building_id_prefix}=          urn:ngsi-ld:Building:
${building_filename}=           building-simple-attributes-sample.jsonld
${subscription_id_prefix}=      urn:ngsi-ld:Subscription:
${subscription_filename}=       csourceSubscriptions/subscription-sample.jsonld


*** Test Cases ***
@@ -25,11 +23,6 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /entities/{entityId})
    [Tags]    e-query    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    ${response}=    Create Entity Selecting Content Type
    ...    ${building_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Query Entity    ${entity_id}    accept=${accept}
    Check Response Status Code    ${status_code}    ${response.status_code}
    [Teardown]    Delete Entity by Id Returning Response    ${entity_id}
@@ -38,8 +31,6 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /subscriptions/{subscriptionId})
    [Tags]    sub-retrieve    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${response}=    Create Subscription    ${id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Retrieve Subscription    ${id}    accept=${accept}
    Check Response Status Code    ${status_code}    ${response.status_code}
    [Teardown]    Delete Subscription    ${id}
+3 −6
Original line number Diff line number Diff line
@@ -12,22 +12,19 @@ Resource ${EXECDIR}/resources/JsonUtils.resource
${accept}=                      application/geo+json
${status_code}=                 406
${subscription_id_prefix}=      urn:ngsi-ld:Subscription:
${subscription_filename}=       csourceSubscriptions/subscription-sample.jsonld


*** Test Cases ***
049_02_01 Retrieve subscription by id
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /subscriptions/{subscriptionId})
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (get /subscriptions/{subscriptionId})
    [Tags]    sub-retrieve    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${response}=    Create Subscription    ${id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Retrieve Subscription    ${id}    accept=${accept}
    Check Response Status Code    ${status_code}    ${response.status_code}
    [Teardown]    Delete Subscription    ${id}

049_02_02 Query temporal entities
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /temporal/entities)
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (get /temporal/entities)
    [Tags]    te-query    6_3_4
    ${entity_types_to_be_retrieved}=    Catenate    SEPARATOR=,    Vehicle
    ${response}=    Query Temporal Representation Of Entities
@@ -38,7 +35,7 @@ ${subscription_filename}= csourceSubscriptions/subscription-sample.jsonld
    Check Response Status Code    ${status_code}    ${response.status_code}

049_02_03 Query context source registration
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header does not imply "application/json" nor "application/ld+json" (get /csourceRegistrations)
    [Documentation]    Verify throwing 406 HTTP status code (Not Acceptable Media Type) if the "Accept" header is "application/geo+json" for operations different than "Retrieve Entity" and "Query Entity" (get /csourceRegistrations)
    [Tags]    csr-query    6_3_4
    ${response}=    Query Context Source Registrations With Return    type=Building    accept=${accept}
    Check Response Status Code    ${status_code}    ${response.status_code}
+0 −7
Original line number Diff line number Diff line
@@ -28,11 +28,6 @@ ${content_type}= application/xml
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /entities/{entityId}/attrs/{attrId})
    [Tags]    ea-partial-update    6_3_4
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    ${response}=    Create Entity Selecting Content Type
    ...    ${vehicle_filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Partial Update Entity Attributes
    ...    ${entity_id}
    ...    ${vehicle_attribute}
@@ -45,8 +40,6 @@ ${content_type}= application/xml
    [Documentation]    Verify throwing 415 HTTP status code (Unsupported Media Type) if "Content-Type" header is not "application/json" or "application/ld+json" (patch /subscriptions/{subscriptionId})
    [Tags]    sub-update    6_3_4
    ${id}=    Generate Random Entity Id    ${subscription_id_prefix}
    ${response}=    Create Subscription    ${id}    ${subscription_filename}    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Update Subscription    ${id}    ${subscription_fragment}    ${content_type}
    Check Response Status Code    415    ${response.status_code}
    [Teardown]    Delete Subscription    ${id}
Loading