Commit d4d05a01 authored by Houcem Kacem's avatar Houcem Kacem
Browse files

feat: add tests for partialsucess and failure for batch entity create

parent 023cd3f2
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you cannot create a batch of entities with an invalid request
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
Resource    ../../../../../../resources/AssertionUtils.resource
Library     REST    ${url}
Library     JSONLibrary

*** Variable ***
${batch_endpoint}=    entityOperations/create
${endpoint}=    entities

*** Test Case ***
With empty json document
    [Documentation]  Check that you cannot create a batch of entities with an invalid json document
    [Tags]  critical

    Batch Create Entities With File   building-invalid.jsonld

    Check Response Status Code Set To  400
 No newline at end of file
+0 −9
Original line number Diff line number Diff line
@@ -64,12 +64,3 @@ Create batch of entities having multiple attributes
    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz

*** Keywords ***
Batch Create Entities
    [Arguments]  @{entities_to_be_created}
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${batch_endpoint}  body=@{entities_to_be_created}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}
+34 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can create a batch of entities where some will succeed and others will fail
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
Resource    ../../../../../../resources/AssertionUtils.resource
Library     REST    ${url}
Library     JSONLibrary

Suite Setup      Create Entity  building-minimal-3.jsonld

*** Variable ***
${batch_endpoint}=    entityOperations/create
${endpoint}=    entities

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

    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-2.jsonld
    ${already_existing_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-3.jsonld
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}     ${already_existing_entity}

    Batch Create Entities   @{entities_to_be_created}

    @{expected_entities_ids}=  Create List   urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9     urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Check Response Status Code Set To  207
    Check Response Body Set To  @{expected_entities_ids}

    #TODO call Batch Delete Entities
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9
    Delete Entity by Id  urn:ngsi-ld:Building:56hy789-eft6-9987-be54-adr45nf567ddz
    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-345789442
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
[

]
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-345789442",
    "type": "Building",
    "@context": [
        "https://fiware.github.io/data-models/context.jsonld",
        "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
    ]
}
 No newline at end of file
Loading