Commit 02eae43d authored by Houcem Kacem's avatar Houcem Kacem
Browse files

feat: improve assertions

parent cb23f288
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Resource ../../../../../../resources/JsonUtils.resource
Library     REST    ${url}
Library     JSONLibrary
Library     String
Library     Collections

*** Variable ***
${batch_endpoint}=    entityOperations/create
@@ -14,7 +15,7 @@ ${endpoint}= entities
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Case ***
Create batch of minimal entities
Create a batch of minimal entities
    [Documentation]  Check that you can create a batch of minimal entities
    [Tags]  critical

@@ -28,13 +29,13 @@ Create batch of minimal entities

    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}
    Check Response Body Containing Array  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}

Create batch of entities having only simple properties
Create a batch of entities having only simple properties
    [Documentation]  Check that you can create a batch of entities having only simple properties
    [Tags]  critical

@@ -48,13 +49,13 @@ Create batch of entities having only simple properties

    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}
    Check Response Body Containing Array  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  ${first_entity_id}
    Delete Entity by Id  ${second_entity_id}

Create batch of entities having multiple attributes
Create a batch of entities having multiple attributes
    [Documentation]  Check that you can create a batch of entities having multiple attributes
    [Tags]  critical

@@ -68,7 +69,7 @@ Create batch of entities having multiple attributes

    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    Check Response Status Code Set To  201
    Check Response Body Set To  @{expected_entities_ids}
    Check Response Body Containing Array  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  ${first_entity_id}
+7 −4
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Resource ../../../../../../resources/JsonUtils.resource
Library     REST    ${url}
Library     JSONLibrary
Library     String
Library     Collections

Suite Setup      Create Entity  building-minimal-sample.jsonld     urn:ngsi-ld:Building:92f041b428b9

@@ -16,8 +17,8 @@ ${endpoint}= entities
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Case ***
Create batch of valid and invalid entities
    [Documentation]  Check that you can create a batch of valid and invalid entities
Create a batch of two valid entities and one invalid entity
    [Documentation]  Check that you can create a batch of two valid entities and one invalid entity
    [Tags]  critical

    ${first_entity_id}=     Generate Random Entity Id    ${building_id_prefix}
@@ -29,9 +30,11 @@ Create batch of valid and invalid entities

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   ${first_entity_id}     ${second_entity_id}
    @{expected_batch_operation_result_success}=  Create List   ${first_entity_id}     ${second_entity_id}
    @{expected_batch_operation_result_errors}=  Create List   urn:ngsi-ld:Building:92f041b428b9
    &{expected_batch_operation_result}=  Create Batch Operation Result   ${expected_batch_operation_result_success}     ${expected_batch_operation_result_errors}
    Check Response Status Code Set To  207
    Check Response Body Set To  @{expected_entities_ids}
    Check Response Body Containing Batch Operation Result   ${expected_batch_operation_result}

    #TODO call Batch Delete Entities
    Delete Entity by Id  ${first_entity_id}
+11 −5
Original line number Diff line number Diff line
*** Keywords ***
Check Response Status Code Set To
    [Arguments]  ${status}
    [Arguments]  ${expected_status}
    ${response_status}=  convert to string  ${response['status']}
    Should Be Equal  ${response_status}  ${status}
    Should Be Equal  ${response_status}  ${expected_status}

Check Response Body Containing Array
    [Arguments]  @{expected_array}
    Lists Should Be Equal  ${response['body']}  ${expected_array}   ignore_order=True

Check Response Body Set To
    [Arguments]  @{expected_entities_ids}
    Should Contain  ${response['body']['success']}  @{expected_entities_ids}
Check Response Body Containing Batch Operation Result
    [Arguments]  ${expected_batch_operation_result}
    @{expected_success}=    Get From Dictionary     ${expected_batch_operation_result}     success
    @{expected_errors}=    Get From Dictionary     ${expected_batch_operation_result}     errors
    Lists Should Be Equal  ${response['body']['success']}  ${expected_success}   ignore_order=True

Assert response status code
    [Arguments]     ${code}
+8 −1
Original line number Diff line number Diff line
@@ -14,3 +14,10 @@ Generate Random Entity Id
    ${entity_id}=    Catenate    ${id_prefix}${random_id}

    [return]    ${entity_id}

Create Batch Operation Result
    [Arguments]    ${success}       ${errors}

    &{batch_operation_result}=      Create Dictionary	success=${success}      errors=${errors}

    [return]    &{batch_operation_result}
 No newline at end of file
+332 B

File added.

No diff preview for this file type.