Commit 023cd3f2 authored by Houcem Kacem's avatar Houcem Kacem
Browse files

feat: move entities payloads under an entities folder + split resources into...

feat: move entities payloads under an entities folder + split resources into ApiUtils and AssertionUtils
parent 8a78d3f7
Loading
Loading
Loading
Loading
+12 −36
Original line number Diff line number Diff line
@@ -2,11 +2,9 @@
Documentation   Check that you can create a batch of entities
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
Library     REST    $url
Library     JSONSchemaLibrary   ${EXECDIR}/schemas
Library     BuiltIn
Library     OperatingSystem

Resource    ../../../../../../resources/AssertionUtils.resource
Library     REST    ${url}
Library     JSONLibrary

*** Variable ***
${batch_endpoint}=    entityOperations/create
@@ -17,11 +15,9 @@ Create batch of minimal entities
    [Documentation]  Check that you can create a batch of minimal entities
    [Tags]  critical

    ${first_minimal_entity}=    Get File    ${EXECDIR}/data/building-minimal.jsonld
    ${second_minimal_entity}=    Get File    ${EXECDIR}/data/building-minimal-2.jsonld
    ${first_minimal_entity_parsed}=    evaluate    json.loads($first_minimal_entity)    json
    ${second_minimal_entity_parsed}=    evaluate    json.loads($second_minimal_entity)    json
    @{entities_to_be_created}=  Create List   ${first_minimal_entity_parsed}     ${second_minimal_entity_parsed}
    ${first_minimal_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal.jsonld
    ${second_minimal_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-minimal-2.jsonld
    @{entities_to_be_created}=  Create List   ${first_minimal_entity}     ${second_minimal_entity}

    Batch Create Entities   @{entities_to_be_created}

@@ -37,11 +33,9 @@ Create batch of entities having only simple properties
    [Documentation]  Check that you can create a batch of entities having only simple properties
    [Tags]  critical

    ${first_entity}=    Get File    ${EXECDIR}/data/building-simple-attributes.jsonld
    ${second_entity}=    Get File    ${EXECDIR}/data/building-simple-attributes-2.jsonld
    ${first_entity_parsed}=    evaluate    json.loads($first_entity)    json
    ${second_entity_parsed}=    evaluate    json.loads($second_entity)    json
    @{entities_to_be_created}=  Create List   ${first_entity_parsed}     ${second_entity_parsed}
    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-simple-attributes.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-simple-attributes-2.jsonld
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

    Batch Create Entities   @{entities_to_be_created}

@@ -57,11 +51,9 @@ Create batch of entities having multiple attributes
    [Documentation]  Check that you can create a batch of entities having multiple attributes
    [Tags]  critical

    ${first_entity}=    Get File    ${EXECDIR}/data/building-relationship-of-property.jsonld
    ${second_entity}=    Get File    ${EXECDIR}/data/building-relationship-of-property-2.jsonld
    ${first_entity_parsed}=    evaluate    json.loads($first_entity)    json
    ${second_entity_parsed}=    evaluate    json.loads($second_entity)    json
    @{entities_to_be_created}=  Create List   ${first_entity_parsed}     ${second_entity_parsed}
    ${first_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-relationship-of-property.jsonld
    ${second_entity}=    Load Json From File    ${EXECDIR}/data/entities/building-relationship-of-property-2.jsonld
    @{entities_to_be_created}=  Create List   ${first_entity}     ${second_entity}

    Batch Create Entities   @{entities_to_be_created}

@@ -81,19 +73,3 @@ Batch Create Entities
    Output  request
    Output  response
    Set Test Variable  ${response}

Check Response Status Code Set To
    [Arguments]  ${status}
    ${response_status}=  convert to string  ${response['status']}
    Should Be Equal  ${response_status}  ${status}

Delete Entity by Id
    [Arguments]  ${id}
    ${response}=  DELETE  ${endpoint}/${id}
    Output  request
    Output  response

Check Response Body Set To
    [Arguments]  @{expected_entities_ids}
    Should Contain  ${response['body']['success']}  @{expected_entities_ids}
+4 −5
Original line number Diff line number Diff line
 
*** Settings ***
Documentation   Check that the IUT refuses to create an entity if one exists with the same identifier 
Variables   ../../../../../../resources/variables.py
Resource    ../../../../../../resources/ApiUtils.resource
#Resource    ../../../../../../resources/ApiUtils.resource
Library     REST    ${url}
Library     JSONSchemaLibrary   ${EXECDIR}/schemas
Library     BuiltIn
@@ -18,17 +19,15 @@ AlreadyExists
    [Tags]  critical  
    Create Entity  building-minimal.jsonld
    Create Entity  building-minimal.jsonld

    Check HTTP Status Code Is  409
    Check HTTP Response Body Json Schema Is  error_response

    Delete Entity by Id  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9

*** Keywords ***
Create Entity  
    [Arguments]  ${filename}    
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${endpoint}  body=${EXECDIR}/data/${filename}  headers=${headers}  
    ${response}=  POST  ${endpoint}  body=${EXECDIR}/data/entities/${filename}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}
+41 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that the IUT accepts the creation of an entity
Variables   ../../../../../../resources/variables.py
Library     REST    ${url}
Library     JSONSchemaLibrary   ${EXECDIR}/schemas

Test Template  Create Entity Scenarios

*** Variable ***
${endpoint}=    entities
${id}=  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9

*** Test Cases ***                        FILENAME
SuccessCases_MinimalEntity                building-minimal.jsonld
SuccessCases_EntityWithSimpleProperties   building-simple-attributes.jsonld

*** Keywords ***
Create Entity Scenarios
     [Arguments]  ${filename}
     Create Entity  ${filename}
     Check HTTP Status Code Is  201
     Delete Entity by Id  ${id}

Create Entity
    [Arguments]  ${filename}
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${endpoint}  body=${EXECDIR}/data/entities/${filename}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}

Check HTTP Status Code Is
    [Arguments]  ${status}
    ${response_status}=  convert to string  ${response['status']}
    Should Be Equal  ${response_status}  ${status}

Delete Entity by Id
    [Arguments]  ${id}
    ${response}=  DELETE  ${endpoint}/${id}
    Output  request
    Output  response
 No newline at end of file
+44 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that the IUT accepts the creation of an entity
Variables   ../../../../../../resources/variables.py
#Resource    ../../../../../../resources/ApiUtils.resource
Library     REST    ${url}

*** Variable ***
${endpoint}=    entities
${id}=  urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9

*** Test Case ***
SuccessCases_MinimalEntity
    [Documentation]  Create an entity with a JSON-LD payload containing the minimal information
    [Tags]  critical
    Create Entity  building-minimal.jsonld
    Check HTTP Status Code Is  201
    Delete Entity by Id  ${id}

SuccessCases_EntityWithSimpleProperties
    [Documentation]  Create an entity with a JSON-LD payload containing only simple properties
    Create Entity  building-simple-attributes.jsonld
    Check HTTP Status Code Is  201
    Delete Entity by Id  ${id}


*** Keywords ***
Create Entity
    [Arguments]  ${filename}
    &{headers}=  Create Dictionary  Content-Type=application/ld+json
    ${response}=  POST  ${endpoint}  body=${EXECDIR}/data/entities/${filename}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}

Check HTTP Status Code Is
    [Arguments]  ${status}
    ${response_status}=  convert to string  ${response['status']}
    Should Be Equal  ${response_status}  ${status}

Delete Entity by Id
    [Arguments]  ${id}
    ${response}=  DELETE  ${endpoint}/${id}
    Output  request
    Output  response
Loading