Commit 22fb57f9 authored by lopesg's avatar lopesg
Browse files

created Provision/Entities/CreateEntity/001.robot tests suite

parent 590f55a7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
resources/__pycache__
results
*.pyc
*.http
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   Check that you can create an entity
Resource    ${EXECDIR}/resources/ApiUtils.resource
Resource    ${EXECDIR}/resources/AssertionUtils.resource
Resource    ${EXECDIR}/resources/JsonUtils.resource

Test Template  Create Entity Scenarios

*** Variable ***
${building_id_prefix}=  urn:ngsi-ld:Building:

*** Test Cases ***                        FILENAME                                              CONTENT_TYPE
MinimalEntity                             building-minimal-without-context-sample.jsonld        application/json
EntityWithSimpleProperties                building-simple-attributes-sample.jsonld              application/ld+json
EntityWithRelationshipsProperties         building-relationship-of-property-sample.jsonld       application/ld+json
#EntityWithNoContext                       building-minimal-without-context-sample.jsonld        application/ld+json
EntityWithLocationAttribute               building-location-attribute.jsonld                    application/ld+json



*** Keywords ***
Create Entity Scenarios
    [Arguments]  ${filename}    ${content_type}
    [Documentation]  Check that you can create an entity
    [Tags]  mandatory   entityOperations

    ${entity_id}=     Generate Random Entity Id    ${building_id_prefix}
    ${entity}=    Load Entity    ${filename}      ${entity_id}

    Create Entity Selecting Content Type   ${filename}      ${entity_id}     ${content_type}
    Check Response Status Code Set To  201
    Check Response Headers Containing URI set to    ${request['path']}    ${entity_id}

    [Teardown]    Delete Entity by Id       ${entity_id}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:Building:randomUUID",
    "type": "Building"
}
 No newline at end of file
+19 −3
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ ${BATCH_UPSERT_ENDPOINT_PATH} entityOperations/upsert
${BATCH_UPDATE_ENDPOINT_PATH}   entityOperations/update
${BATCH_DELETE_ENDPOINT_PATH}   entityOperations/delete
&{BATCH_OPERATION_ENDPOINT_MAPPING}    create=${BATCH_CREATE_ENDPOINT_PATH}    upsert=${BATCH_UPSERT_ENDPOINT_PATH}    update=${BATCH_UPDATE_ENDPOINT_PATH}    delete=${BATCH_DELETE_ENDPOINT_PATH}
${ENTITIES_ENDPOINT_PATH}       entities
${ENTITIES_ENDPOINT_PATH}       entities/
#${ENTITIES_ENDPOINT_PATH}       entities original
${TEMPORAL_ENTITIES_ENDPOINT_PATH}       temporal/entities

${CONTENT_TYPE_JSON}            application/json
@@ -51,7 +52,8 @@ Api DEL request

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

@@ -65,6 +67,19 @@ Retrieve Entity by Id
    Output  response
    Set Test Variable    ${response}

Create Entity Selecting Content Type
    [Arguments]  ${filename}    ${entity_id}    ${content_type}
    ${entity_payload}=    Load Json From File    ${EXECDIR}/data/entities/${filename}
    ${entity}=    Update Value To Json    ${entity_payload}     $..id   ${entity_id}

    &{headers}=  Create Dictionary  Content-Type=${content_type}
    ${response}=  POST  ${ENTITIES_ENDPOINT_PATH}  body=${entity}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}
    ${request}=    Output  request
    Set Test Variable  ${request}

Create Entity
    [Arguments]  ${filename}    ${entity_id}
    ${entity_payload}=    Load Json From File    ${EXECDIR}/data/entities/${filename}
@@ -74,6 +89,7 @@ Create Entity
    ${response}=  POST  ${ENTITIES_ENDPOINT_PATH}  body=${entity}  headers=${headers}
    Output  request
    Output  response
    Set Test Variable  ${response}

Batch Create Entities
    [Arguments]  @{entities_to_be_created}      ${content_type}=${CONTENT_TYPE_LD_JSON}     ${context}=${EMPTY}
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ Check Response Body Containing Array Of URIs set to
    [Arguments]  @{expected_entities_ids}
    Lists Should Be Equal  ${expected_entities_ids}        ${response['body']}     ignore_order=True

Check Response Headers Containing URI set to
# upon success, the http response shall include a loication http header that countains the uri of the created entity resource
    [Arguments]  ${expected_path}    ${expected_entity_id}
    Should Be Equal  ${expected_path}${expected_entity_id}        ${response['headers']['location']}     ignore_order=True

Check Response Body Containing an Attribute set to
    [Arguments]  ${expected_attribute_name}
    Should Not Be Empty     ${response['body']['${expected_attribute_name}']}
Loading