Commit 659daf1f authored by lopesg's avatar lopesg
Browse files

added create subscriptions suite

parent d57e222f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -13,12 +13,12 @@ ${filename}= vehicle-two-datasetid-attributes-sample.jsonld
${status_code}=  400

*** Test Cases ***                                                                  ENTITY_ID               ATTRIBUTE_ID          FRAGMENT_FILENAME
#012_02_01_Make a partial attribute update if the Entity Id is not present              ${EMPTY}                speed                 vehicle-speed-equal-datasetid-fragment.jsonld
#012_02_02_Make a partial attribute update if the Entity Id is not a valid URI          thisisaninvaliduri      speed                 vehicle-speed-equal-datasetid-fragment.jsonld
012_02_01_Make a partial attribute update if the Entity Id is not present              ${EMPTY}                speed                 vehicle-speed-equal-datasetid-fragment.jsonld
012_02_02_Make a partial attribute update if the Entity Id is not a valid URI          thisisaninvaliduri      speed                 vehicle-speed-equal-datasetid-fragment.jsonld
012_02_03_Make a partial attribute update if the Attribute Name is not present         ${valid_entity_id}      speed                 vehicle-speed-wrong-name-fragment.jsonld
#012_02_04_Make a partial attribute update if the Attribute Id is invalid               ${valid_entity_id}      invalid               vehicle-speed-equal-datasetid-fragment.jsonld
#012_02_05_Make a partial attribute update if the Attribute type does not match         ${valid_entity_id}      speed                 vehicle-speed-equal-datasetid-different-type-fragment.jsonld
#012_02_06_Make a partial attribute update if the entity fragment is empty              ${valid_entity_id}      speed                 empty-fragment.jsonld
012_02_04_Make a partial attribute update if the Attribute Id is invalid               ${valid_entity_id}      invalid               vehicle-speed-equal-datasetid-fragment.jsonld
012_02_05_Make a partial attribute update if the Attribute type does not match         ${valid_entity_id}      speed                 vehicle-speed-equal-datasetid-different-type-fragment.jsonld
012_02_06_Make a partial attribute update if the entity fragment is empty              ${valid_entity_id}      speed                 empty-fragment.jsonld

*** Keywords ***
Update Attributes
+24 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can create a subscription
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   subscriptions/subscription-sample.jsonld

*** Test Cases ***
Create Subscription   
    [Documentation]  Check that you can create a subscription
    [Tags]  /entities/    5_6_1

    ${subscription_id}=     Generate Random Entity Id    ${subscription_id_prefix}

    Create Subscription  ${subscription_id}     ${subscription_payload_file_path}   ${CONTENT_TYPE_LD_JSON}
    
    ${created_subscription}=    Load Test Sample    ${subscription_payload_file_path}      ${subscription_id}
    Retrieve Subscription    ${subscription_id}     context=${ngsild_test_suite_context}
    Check Created Resource Set To     ${created_subscription}

    [Teardown]    Delete Subscription     ${subscription_id}
 No newline at end of file
+22 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot create a subscription with an invalid request
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource

Test Template  Create Subscription With Invalid Request

*** Test Cases ***                           FILENAME                         
031_02_01_InvalidJson                        subscription-invalid-json-sample.jsonld            
031_02_02_EmptyJson                          subscription-empty-sample.jsonld    

*** Keywords ***
Create Subscription With Invalid Request
    [Arguments]  ${filename}
    [Documentation]  Check that you cannot create a subscription with an invalid request
    [Tags]   /entities/    5_6_1

    Create Subscription From File   ${filename}

    Check RL Response Status Code Set To Expected Code    400
    Check RL Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check RL Response Body Containing ProblemDetails Element Containing Title Element    ${response}
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot create a subscription with an invalid/empty id
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Create Subscription With Invalid/Empty Id

*** Variables ***
${subscription_payload_file_path}=  subscriptions/subscription-sample.jsonld

*** Test Cases ***               ID                         
031_03_01_InvalidId              invalidId       
031_03_02_EmptyId                ${EMPTY}   

*** Keywords ***
Create Subscription With Invalid/Empty Id
    [Arguments]  ${subscription_id}
    [Documentation]  Check that you cannot create a subscription with an invalid/empty id
    [Tags]   /entities/    5_6_1

    ${response}=  Create Subscription  ${subscription_id}     ${subscription_payload_file_path}    ${CONTENT_TYPE_LD_JSON}
    
    Check Response Status Code  400    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_BAD_REQUEST_DATA}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}

    [Teardown]    Delete Subscription     ${subscription_id}
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot create a subscription with an existing id
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

*** Variable ***
${subscription_id_prefix}=  urn:ngsi-ld:Subscription:
${subscription_payload_file_path}=   subscriptions/subscription-sample.jsonld

*** Test Case ***
Create a subscription with an id known to the system
    [Documentation]  Check that you cannot create a subscription with an existing id
    [Tags]   /entities/    5_6_1

    ${subscription_id}=     Generate Random Entity Id    ${subscription_id_prefix}
    Create Subscription  ${subscription_id}     ${subscription_payload_file_path}    ${CONTENT_TYPE_LD_JSON}
    
    ${response}=  Create Subscription  ${subscription_id}     ${subscription_payload_file_path}    ${CONTENT_TYPE_LD_JSON}

    Check Response Status Code  409    ${response['status']}
    Check Response Body Containing ProblemDetails Element Containing Type Element set to      ${response}     ${ERROR_TYPE_ALREADY_EXISTS}
    Check Response Body Containing ProblemDetails Element Containing Title Element    ${response}

    [Teardown]    Delete Subscription     ${subscription_id}
Loading