Commit e2b97d8e authored by Patricia dos Santos Oliveira's avatar Patricia dos Santos Oliveira
Browse files

Fix test CreateEntity_200_Minimal. Add test CreateEntity_409_AlreadyExists

parent 7f51dcc0
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation   TP description.
Variables   ../../../../../resources/variables.py
Library     REST    ${url}
Library     JSONSchemaLibrary   ${CURDIR}/schemas
Library     OperatingSystem
Library     String

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

*** Variable ***
${endpoint}=    entities

*** Test Case ***
CreateEntity_200_Minimal
    [Documentation]  TP Variation description.
    [Tags]  critical  
    Create Entity  building-minimal.jsonld
    Check HTTP Status Code Is  201

CreateEntity_409_AlreadyExists
    Create Entity  building-minimal.jsonld
    Check HTTP Status Code Is  409
    Check HTTP Response Body Json Schema Is  error_response

*** Keywords ***
Create Entity  
    [Arguments]  ${filename}    
    &{headers}=  Create Dictionary  Content-Type=application/ld+json    authorization=Bearer ${token}
    ${response}=  POST  ${endpoint}  body=${CURDIR}/data/${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}

Check HTTP Response Body Json Schema Is
    [Arguments]  ${input}
    Should Contain  ${response['headers']['Content-Type']}  application/json
    ${schema}=  Catenate  SEPARATOR=  ${input}  .schema.json
    Validate Json  ${schema}  ${response['body']}
    Log  Json Schema Validation OK

Delete Entity by Id
    [Arguments]  ${id}    
    &{headers}=  Create Dictionary  authorization=Bearer ${token}
    ${response}=  DELETE  ${endpoint}/${id}  headers=${headers}  
    Output  request
    Output  response
 No newline at end of file
+0 −44
Original line number Diff line number Diff line
*** Settings ***
Documentation   TP description.
Variables   ../../../../../resources/variables.py
Library     REST    ${url}
Library     JSONSchemaLibrary   .schemas/
Library     OperatingSystem

#Suite Setup 
#Suite Teardown

*** Variable ***
${endpoint}=    entities


*** Test Case ***
CreateEntity_200_MINIMAL
    [Documentation]  TP Variation description.
    [Tags]  critical
    Log To Console  "Will start Test Case CreateEntity_200_MINIMAL ..."
    #TO DO: read body from files
    Create Entity   {"id": "urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9", "type": "Building"}
    Check HTTP Status Code Is  201
    Check HTTP Response Body Json Schema Is  response.json   

*** Keywords ***
Create Entity  
    [Arguments]    ${body}    
    ${response}    POST    ${endpoint}      body=${body}
    Output    request
    Output    response
    Set Test Variable    ${response}

Check HTTP Status Code Is 
    [Arguments]    ${status}
    Log To Console  ${response}
    Should Be Equal    ${response['status']}    ${status}

Check HTTP Response Body Json Schema Is
    [Arguments]    ${input}
    Should Contain    ${response['headers']['Content-Type']}    application/json
    ${schema} =    Catenate    SEPARATOR=    ${input}    .schema.json
    Validate Json    ${schema}    ${response['body']}
    Log    Json Schema Validation OK
+7 −0
Original line number Diff line number Diff line
{
    "required": [
        "detail",
        "type",
        "title"
    ]
}
 No newline at end of file
+0 −73
Original line number Diff line number Diff line
{
    "required": [
        "timestamp",
        "path",
        "status",
        "error",
        "message",
        "requestId"
    ],
    "properties": {
        "timestamp": {
            "$id": "#/properties/timestamp",
            "type": "integer",
            "title": "The timestamp schema",
            "description": "An explanation about the purpose of this instance.",
            "default": 0,
            "examples": [
                1599842686277
            ]
        },
        "path": {
            "$id": "#/properties/path",
            "type": "string",
            "title": "The path schema",
            "description": "An explanation about the purpose of this instance.",
            "default": "",
            "examples": [
                "/ngsi-ld/v1/entities"
            ]
        },
        "status": {
            "$id": "#/properties/status",
            "type": "integer",
            "title": "The status schema",
            "description": "An explanation about the purpose of this instance.",
            "default": 0,
            "examples": [
                415
            ]
        },
        "error": {
            "$id": "#/properties/error",
            "type": "string",
            "title": "The error schema",
            "description": "An explanation about the purpose of this instance.",
            "default": "",
            "examples": [
                "Unsupported Media Type"
            ]
        },
        "message": {
            "$id": "#/properties/message",
            "type": "string",
            "title": "The message schema",
            "description": "An explanation about the purpose of this instance.",
            "default": "",
            "examples": [
                "Content type '' not supported"
            ]
        },
        "requestId": {
            "$id": "#/properties/requestId",
            "type": "string",
            "title": "The requestId schema",
            "description": "An explanation about the purpose of this instance.",
            "default": "",
            "examples": [
                "9a15420d-86"
            ]
        }
    },
    "additionalProperties": true
}
 No newline at end of file
Loading