From 22fb57f9424aea70ebd36ed10b29c7de131d810b Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Tue, 22 Dec 2020 15:19:30 +0000 Subject: [PATCH 1/5] created Provision/Entities/CreateEntity/001.robot tests suite --- .gitignore | 1 + .../Provision/Entities/CreateEntity/001.robot | 34 +++++++++++++++++++ ...ding-minimal-without-context-sample.jsonld | 4 +++ resources/ApiUtils.resource | 22 ++++++++++-- resources/AssertionUtils.resource | 5 +++ resources/variables.py | 2 +- 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot create mode 100644 data/entities/building-minimal-without-context-sample.jsonld diff --git a/.gitignore b/.gitignore index 3e9e56a4..438bfca9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ resources/__pycache__ results *.pyc +*.http \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot new file mode 100644 index 00000000..920caa27 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot @@ -0,0 +1,34 @@ +*** 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 diff --git a/data/entities/building-minimal-without-context-sample.jsonld b/data/entities/building-minimal-without-context-sample.jsonld new file mode 100644 index 00000000..78ff3565 --- /dev/null +++ b/data/entities/building-minimal-without-context-sample.jsonld @@ -0,0 +1,4 @@ +{ + "id": "urn:ngsi-ld:Building:randomUUID", + "type": "Building" +} \ No newline at end of file diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 13733600..52f19e04 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -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 @@ -63,7 +65,20 @@ Retrieve Entity by Id ${response}= GET ${ENTITIES_ENDPOINT_PATH}/${id} headers=${headers} Output request Output response - Set Test Variable ${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} @@ -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} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 0b31186a..fc090ca2 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -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}']} diff --git a/resources/variables.py b/resources/variables.py index 1917f8e8..881e64b3 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -1,6 +1,6 @@ def get_variables(arg=None): variables = { - 'url': 'http://10.5.1.214:9090/ngsi-ld/v1', + 'url': 'http://localhost:9090/ngsi-ld/v1', 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld' } return variables -- GitLab From 66719a60eadfdaa42e8980dcc398a50913396fa3 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Tue, 22 Dec 2020 18:12:22 +0000 Subject: [PATCH 2/5] created Provision/Entities/CreateEntity/002.robot --- .../Provision/Entities/CreateEntity/002.robot | 22 +++++++++++++++++++ data/entities/empty-sample.jsonld | 1 + data/entities/invalid-json-sample.jsonld | 10 +++++++++ resources/ApiUtils.resource | 14 ++++++++++-- resources/AssertionUtils.resource | 4 ++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot create mode 100644 data/entities/empty-sample.jsonld create mode 100644 data/entities/invalid-json-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot new file mode 100644 index 00000000..3a46d47d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot @@ -0,0 +1,22 @@ +*** Settings *** +Documentation Check that you cannot create an entity with an invalid request +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource + +Test Template Create Entity With Invalid Request Scenarios + +*** Test Cases *** FILENAME PROBLEM_TYPE EXPECTED_CODE +InvalidJson invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST} 406 +EmptyJson empty-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} 400 + +*** Keywords *** +Create Entity With Invalid Request Scenarios + [Arguments] ${filename} ${problem_type} ${expected_code} + [Documentation] Check that you cannot create an entity with an invalid request + [Tags] mandatory + + Request Entity From File ${filename} + + Check RL Response Status Code Set To Expected Code ${expected_code} + Check RL Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${problem_type} + Check RL Response Body Containing ProblemDetails Element Containing Title Element ${response} \ No newline at end of file diff --git a/data/entities/empty-sample.jsonld b/data/entities/empty-sample.jsonld new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/data/entities/empty-sample.jsonld @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/data/entities/invalid-json-sample.jsonld b/data/entities/invalid-json-sample.jsonld new file mode 100644 index 00000000..dcbdb010 --- /dev/null +++ b/data/entities/invalid-json-sample.jsonld @@ -0,0 +1,10 @@ +[ + { + "id":"urn:ngsi-ld:Building:randomUUID",, + "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 diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 52f19e04..01d6d9f4 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -19,8 +19,10 @@ ${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json -${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData -${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest +#${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData original +${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData +#${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest original +${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest ${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound ${response} @@ -125,6 +127,14 @@ Batch Delete Entities Output response Run Keyword If not ${teardown} Set Test Variable ${response} +Request Entity From File + [Arguments] ${filename} + ${file_content}= Get File ${EXECDIR}/data/entities/${filename} + Create Session OneRequest ${url} + &{headers}= Create Dictionary Content-Type=application/ld+json + ${response}= POST Request OneRequest ${ENTITIES_ENDPOINT_PATH} data=${file_content} headers=${headers} + Set Test Variable ${response} + Batch Request Entities From File [Arguments] ${batchOperation} ${filename} ${file_content}= Get File ${EXECDIR}/data/entities/${filename} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index fc090ca2..413628d1 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -10,6 +10,10 @@ Check Response Status Code Set To ${response_status}= convert to string ${response['status']} Should Be Equal ${response_status} ${expected_status} +Check RL Response Status Code Set To Expected Code + [Arguments] ${expected_status} + Status Should Be ${expected_status} ${response} + Check RL Response Status Code Set To [Arguments] ${expected_status} Status Should Be ${expected_status} ${response} -- GitLab From a824be126a32c3f8398fc6a37a40e0a4d4337576 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 23 Dec 2020 09:59:20 +0000 Subject: [PATCH 3/5] created Provision/Entities/CreateEntity/003.robot --- .../Provision/Entities/CreateEntity/001.robot | 1 - .../Provision/Entities/CreateEntity/003.robot | 26 +++++++++++++++++++ resources/AssertionUtils.resource | 4 +++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot index 920caa27..d64edec0 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot @@ -25,7 +25,6 @@ Create Entity Scenarios [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 diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot new file mode 100644 index 00000000..a0257a3d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Check that you cannot create an entity with and existing id +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${building_id_prefix}= urn:ngsi-ld:Building: +${expected_error_message}= Already exists. + +*** Test Case *** +Create one valid entity and one invalid entity + [Documentation] Check that you cannot create an entity with and existing id + [Tags] mandatory + + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + Create Entity building-minimal-sample.jsonld ${entity_id} + Check Response Status Code Set To 201 + + #creating entity with the same id + Create Entity building-minimal-sample.jsonld ${entity_id} + Check Response Status Code Set To 409 + Check Response Body Details Containing Information Error ${expected_error_message} + + [Teardown] Delete Entity by Id ${entity_id} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 413628d1..5ac51d6b 100644 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -31,6 +31,10 @@ Check Response Body Containing an Attribute set to [Arguments] ${expected_attribute_name} Should Not Be Empty ${response['body']['${expected_attribute_name}']} +Check Response Body Details Containing Information Error + [Arguments] ${expected_error_message} + Should be Equal ${expected_error_message} ${response['body']['details']} + Check Response Body Containing Batch Operation Result [Arguments] ${expected_batch_operation_result} @{expected_successful_entities_ids}= Get From Dictionary ${expected_batch_operation_result} success -- GitLab From 3acae9035059a1c0aa2356c1dfd2e977741486bc Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Wed, 23 Dec 2020 10:44:26 +0000 Subject: [PATCH 4/5] refactored some keywords --- .../Provision/Entities/CreateEntity/003.robot | 10 ++++++---- resources/ApiUtils.resource | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot index a0257a3d..973171d8 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/003.robot @@ -7,6 +7,8 @@ Resource ${EXECDIR}/resources/JsonUtils.resource *** Variable *** ${building_id_prefix}= urn:ngsi-ld:Building: ${expected_error_message}= Already exists. +${filename}= building-minimal-sample.jsonld +${content_type}= application/ld+json *** Test Case *** Create one valid entity and one invalid entity @@ -14,13 +16,13 @@ Create one valid entity and one invalid entity [Tags] mandatory ${entity_id}= Generate Random Entity Id ${building_id_prefix} - - Create Entity building-minimal-sample.jsonld ${entity_id} + Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} Check Response Status Code Set To 201 - + #creating entity with the same id - Create Entity building-minimal-sample.jsonld ${entity_id} + Create Entity Selecting Content Type ${filename} ${entity_id} ${content_type} Check Response Status Code Set To 409 Check Response Body Details Containing Information Error ${expected_error_message} [Teardown] Delete Entity by Id ${entity_id} + diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 01d6d9f4..ef14f4ef 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -91,7 +91,6 @@ 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} -- GitLab From ff84262fd746485329bcaaca1595ef9f526af297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patr=C3=ADcia=20Oliveira?= Date: Wed, 23 Dec 2020 11:37:58 +0000 Subject: [PATCH 5/5] remove unused files and lines --- .../Provision/Entities/CreateEntity/001.robot | 10 ++-- .../Provision/Entities/CreateEntity/002.robot | 4 +- .../Entities/CreateEntity/AlreadyExists.robot | 50 ------------------- .../SuccessCases-datadriven.robot | 41 --------------- .../Entities/CreateEntity/SuccessCases.robot | 44 ---------------- resources/ApiUtils.resource | 4 -- resources/variables.py | 1 + 7 files changed, 8 insertions(+), 146 deletions(-) delete mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/AlreadyExists.robot delete mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases-datadriven.robot delete mode 100644 TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases.robot diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot index d64edec0..9ce9d5cf 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001.robot @@ -10,11 +10,11 @@ Test Template Create Entity Scenarios ${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 +001_01_MinimalEntity building-minimal-without-context-sample.jsonld application/json +001_02_EntityWithSimpleProperties building-simple-attributes-sample.jsonld application/ld+json +001_03_EntityWithRelationshipsProperties building-relationship-of-property-sample.jsonld application/ld+json +#001_04_EntityWithNoContext building-minimal-without-context-sample.jsonld application/ld+json +001_05_EntityWithLocationAttribute building-location-attribute.jsonld application/ld+json diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot index 3a46d47d..8885ef5d 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/002.robot @@ -6,8 +6,8 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Test Template Create Entity With Invalid Request Scenarios *** Test Cases *** FILENAME PROBLEM_TYPE EXPECTED_CODE -InvalidJson invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST} 406 -EmptyJson empty-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} 400 +002_01_InvalidJson invalid-json-sample.jsonld ${ERROR_TYPE_INVALID_REQUEST} 406 +002_02_EmptyJson empty-sample.jsonld ${ERROR_TYPE_BAD_REQUEST_DATA} 400 *** Keywords *** Create Entity With Invalid Request Scenarios diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/AlreadyExists.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/AlreadyExists.robot deleted file mode 100644 index ef8a8050..00000000 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/AlreadyExists.robot +++ /dev/null @@ -1,50 +0,0 @@ -*** 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 -Library REST ${url} -Library JSONSchemaLibrary ${EXECDIR}/schemas -Library BuiltIn - -#Suite Setup Create Entity building-minimal.jsonld -#Suite Teardown Delete Entity by Id urn:ngsi-ld:Building:3009ef20-9f62-41f5-bd66-92f041b428b9 - -*** Variable *** -${endpoint}= entities - -*** Test Case *** -AlreadyExists - [Documentation] Check that the IUT refuses to create an entity if one exists with the same identifier - [Tags] mandatory - 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/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} - -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} - ${response}= DELETE ${endpoint}/${id} - Output request - Output response \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases-datadriven.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases-datadriven.robot deleted file mode 100644 index d4a31dd4..00000000 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases-datadriven.robot +++ /dev/null @@ -1,41 +0,0 @@ -*** 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 diff --git a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases.robot b/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases.robot deleted file mode 100644 index 47474e20..00000000 --- a/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/SuccessCases.robot +++ /dev/null @@ -1,44 +0,0 @@ -*** 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] mandatory - 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 diff --git a/resources/ApiUtils.resource b/resources/ApiUtils.resource index 246b3159..9bd4b663 100644 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -13,16 +13,13 @@ ${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 original ${TEMPORAL_ENTITIES_ENDPOINT_PATH} temporal/entities ${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH} temporal/entityOperations ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json -#${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/errors/BadRequestData original ${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData -#${ERROR_TYPE_INVALID_REQUEST} https://uri.etsi.org/ngsi-ld/errors/InvalidRequest original ${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest ${ERROR_TYPE_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound @@ -55,7 +52,6 @@ Api DEL request Delete Entity by Id [Arguments] ${id} - #${response}= DELETE ${ENTITIES_ENDPOINT_PATH}/${id} original ${response}= DELETE ${ENTITIES_ENDPOINT_PATH}${id} Output request Output response diff --git a/resources/variables.py b/resources/variables.py index 881e64b3..88e1f536 100644 --- a/resources/variables.py +++ b/resources/variables.py @@ -4,3 +4,4 @@ def get_variables(arg=None): 'ngsild_test_suite_context': 'https://raw.githubusercontent.com/easy-global-market/ngsild-api-data-models/feature/add-json-ld-context-for-ngsi-ld-test-suite/ngsi-ld-test-suite/ngsi-ld-test-suite-context.jsonld' } return variables + \ No newline at end of file -- GitLab