From 2718cc196b71fa4de03b719e34d7e7fe686605f1 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sun, 21 Jan 2024 07:09:20 +0100 Subject: [PATCH 1/2] feat: add tests for batch operations with more than one instance of the same entity --- .../CreateBatchOfEntities/003_10.robot | 43 +++++++++++++++++++ .../DeleteBatchOfEntities/006_04.robot | 38 ++++++++++++++++ .../UpsertBatchOfEntities/004_07.robot | 37 ++++++++++++++++ .../ContextInformation/Provision/003_10.json | 36 ++++++++++++++++ .../ContextInformation/Provision/004_07.json | 36 ++++++++++++++++ .../ContextInformation/Provision/006_04.json | 36 ++++++++++++++++ .../test_ContextInformation_Provision.py | 21 +++++++++ 7 files changed, 247 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/BatchEntities/CreateBatchOfEntities/003_10.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_04.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_07.robot create mode 100644 doc/files/ContextInformation/Provision/003_10.json create mode 100644 doc/files/ContextInformation/Provision/004_07.json create mode 100644 doc/files/ContextInformation/Provision/006_04.json diff --git a/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/CreateBatchOfEntities/003_10.robot b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/CreateBatchOfEntities/003_10.robot new file mode 100644 index 00000000..b719a9a3 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/CreateBatchOfEntities/003_10.robot @@ -0,0 +1,43 @@ +*** Settings *** +Documentation Check that you can create a batch of entities where two have the same id + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Teardown Delete Entities + + +*** Variables *** +${building_id_prefix}= urn:ngsi-ld:Building: + + +*** Test Cases *** +003_10_01 Create a batch of three valid entities where two have the same id + [Documentation] Check that you can create a batch of entities where two have the same id + [Tags] be-create 5_6_7 since_v1.5.1 + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + Set Suite Variable ${first_entity_id} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + Set Suite Variable ${second_entity_id} + ${first_entity}= Load Entity building-minimal-sample.jsonld ${first_entity_id} + ${second_entity}= Load Entity building-minimal-sample.jsonld ${second_entity_id} + @{entities_to_be_created}= Create List ${first_entity} ${second_entity} ${first_entity} + + ${response}= Batch Create Entities @{entities_to_be_created} + + @{expected_successful_entities_ids}= Create List ${first_entity_id} ${second_entity_id} + Set Test Variable @{expected_successful_entities_ids} + @{expected_failed_entities_ids}= Create List ${first_entity_id} + &{expected_batch_operation_result}= Create Batch Operation Result + ... ${expected_successful_entities_ids} + ... ${expected_failed_entities_ids} + Check Response Status Code 207 ${response.status_code} + Check Response Body Containing Batch Operation Result ${expected_batch_operation_result} ${response.json()} + + +*** Keywords *** +Delete Entities + ${response}= Batch Delete Entities + ... entities_ids_to_be_deleted=@{expected_successful_entities_ids} diff --git a/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_04.robot b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_04.robot new file mode 100644 index 00000000..2f550a03 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_04.robot @@ -0,0 +1,38 @@ +*** Settings *** +Documentation Check that you can delete a batch of entities with the same id + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Setup Setup Initial Entity + + +*** Variables *** +${building_id_prefix}= urn:ngsi-ld:Building: + + +*** Test Cases *** +006_04_01 Delete a batch of existing entities with the same id + [Documentation] Check that you can delete a batch entities with the same id + [Tags] be-delete 5_6_10 since_v1.5.1 + ${new_entity_id}= Generate Random Entity Id ${building_id_prefix} + @{entities_ids_to_be_deleted}= Create List ${entity_id} ${entity_id} + + ${response}= Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} + + @{expected_successful_entities_ids}= Create List ${entity_id} + @{expected_failed_entities_ids}= Create List ${entity_id} + &{response1}= Create Batch Operation Result + ... ${expected_successful_entities_ids} + ... ${expected_failed_entities_ids} + Check Response Status Code 207 ${response.status_code} + Check Response Body Containing Batch Operation Result ${response1} ${response.json()} + + +*** Keywords *** +Setup Initial Entity + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + Create Entity building-simple-attributes-sample.jsonld ${entity_id} + Set Test Variable ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_07.robot b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_07.robot new file mode 100644 index 00000000..16090b79 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_07.robot @@ -0,0 +1,37 @@ +*** Settings *** +Documentation Check that you can upsert a batch of entities where two have the same id + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Teardown Delete Entities + + +*** Variables *** +${building_id_prefix}= urn:ngsi-ld:Building: + + +*** Test Cases *** +004_07_01 Upsert a batch of three valid entities where two have the same id + [Documentation] Check that you can upsert a batch of where two have the same id + [Tags] be-upsert 5_6_8 since_v1.5.1 + ${first_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${second_entity_id}= Generate Random Entity Id ${building_id_prefix} + ${first_entity}= Load Entity building-minimal-sample.jsonld ${first_entity_id} + ${second_entity}= Load Entity building-minimal-sample.jsonld ${second_entity_id} + @{entities_to_be_upserted}= Create List ${first_entity} ${second_entity} ${first_entity} + + ${response}= Batch Upsert Entities @{entities_to_be_upserted} + + @{expected_successful_entities_ids}= Create List ${first_entity_id} ${second_entity_id} + Set Test Variable @{expected_successful_entities_ids} + Check Response Status Code 201 ${response.status_code} + Check Response Body Containing Array Of URIs set to ${expected_successful_entities_ids} ${response.json()} + + +*** Keywords *** +Delete Entities + ${response}= Batch Delete Entities + ... entities_ids_to_be_deleted=@{expected_successful_entities_ids} diff --git a/doc/files/ContextInformation/Provision/003_10.json b/doc/files/ContextInformation/Provision/003_10.json new file mode 100644 index 00000000..a81815c2 --- /dev/null +++ b/doc/files/ContextInformation/Provision/003_10.json @@ -0,0 +1,36 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/BE/003_10", + "test_objective": "Check that you can create a batch of entities where two have the same id", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.7", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.6.7" + ], + "pics_selection": "", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "003_10_01 Create a batch of three valid entities where two have the same id", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/003_10_01", + "doc": "Check that you can create a batch of entities where two have the same id", + "tags": [ + "5_6_7", + "be-create", + "since_v1.5.1" + ], + "setup": null, + "teardown": "Delete Entities", + "template": null, + "then": "then {\n the SUT sends a valid Response for the operations:\n Batch Create Entities with Response Status Code set to 207 and\n Batch Create Entities with Response body containing batch operation result set to '${expected_batch_operation_result}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/create'\n method set to 'POST'\n Request Header['Content-Type'] set to '' and\n payload set to a list of entities to be created\n}", + "http_verb": "POST", + "endpoint": "entityOperations/create" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/BatchEntities/CreateBatchOfEntities", + "robotfile": "003_10" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/004_07.json b/doc/files/ContextInformation/Provision/004_07.json new file mode 100644 index 00000000..170b1f2c --- /dev/null +++ b/doc/files/ContextInformation/Provision/004_07.json @@ -0,0 +1,36 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/BE/004_07", + "test_objective": "Check that you can upsert a batch of entities where two have the same id", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.8", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.6.8" + ], + "pics_selection": "", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "004_07_01 Upsert a batch of three valid entities where two have the same id", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/004_07_01", + "doc": "Check that you can upsert a batch of where two have the same id", + "tags": [ + "5_6_8", + "be-upsert", + "since_v1.5.1" + ], + "setup": null, + "teardown": "Delete Entities", + "template": null, + "then": "then {\n the SUT sends a valid Response for the operations:\n Batch Upsert Entities with Response Status Code set to 201 and\n Batch Upsert Entities with Response Body set to an array of created entities ids\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/upsert?options=${update_option}'\n method set to 'POST'\n Request batch upsert operation over entity from filename '@{entities_to_be_upserted}' with update_option set to 'replace' and Content-Type set to 'application/ld+json'\n}", + "http_verb": "POST", + "endpoint": "entityOperations/upsert?options=${update_option}" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities", + "robotfile": "004_07" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Provision/006_04.json b/doc/files/ContextInformation/Provision/006_04.json new file mode 100644 index 00000000..b77f5437 --- /dev/null +++ b/doc/files/ContextInformation/Provision/006_04.json @@ -0,0 +1,36 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Prov/BE/006_04", + "test_objective": "Check that you can delete a batch of entities with the same id", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.10", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.6.10" + ], + "pics_selection": "", + "keywords": [], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} \n with an id set to ${entityId} \n}", + "test_cases": [ + { + "name": "006_04_01 Delete a batch of existing entities with the same id", + "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/006_04_01", + "doc": "Check that you can delete a batch entities with the same id", + "tags": [ + "5_6_10", + "be-delete", + "since_v1.5.1" + ], + "setup": "Setup Initial Entity", + "teardown": null, + "template": null, + "then": "then {\n the SUT sends a valid Response for the operations:\n Batch Delete Entities with Response Status Code set to 207 and\n ${response.json()} with Response body containing batch operation result set to '${response1}'\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entityOperations/delete'\n method set to 'POST'\n Batch Delete Entities: and\n Query Parameter: entities_ids_to_be_deleted set to '@{entities_ids_to_be_deleted}'\n}", + "http_verb": "POST", + "endpoint": "entityOperations/delete" + } + ], + "permutations": [], + "robotpath": "ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities", + "robotfile": "006_04" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Provision.py b/doc/tests/test_ContextInformation_Provision.py index 36f34dba..e9970bd6 100644 --- a/doc/tests/test_ContextInformation_Provision.py +++ b/doc/tests/test_ContextInformation_Provision.py @@ -105,6 +105,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_003_10(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/CreateBatchOfEntities/003_10.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/003_10.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_003_10.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_006_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/006_01.json' @@ -126,6 +133,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_006_04(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/DeleteBatchOfEntities/006_04.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/006_04.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_006_04.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_005_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities/005_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/005_01.json' @@ -196,6 +210,13 @@ class TestCIProvision(TestCase): self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_004_07(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/BatchEntities/UpsertBatchOfEntities/004_07.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/004_07.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_004_07.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + def test_001_01(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Provision/Entities/CreateEntity/001_01.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Provision/001_01.json' -- GitLab From 4cc3aa2b93c9ebb153cbf5d8111fdedd360ad1d8 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 23 Mar 2024 10:09:50 +0100 Subject: [PATCH 2/2] chore: update generated doc --- doc/files/ContextInformation/Provision/003_10.json | 8 +++++--- doc/files/ContextInformation/Provision/004_07.json | 8 +++++--- doc/files/ContextInformation/Provision/006_04.json | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/files/ContextInformation/Provision/003_10.json b/doc/files/ContextInformation/Provision/003_10.json index a81815c2..c1b98610 100644 --- a/doc/files/ContextInformation/Provision/003_10.json +++ b/doc/files/ContextInformation/Provision/003_10.json @@ -1,14 +1,16 @@ { "tp_id": "TP/NGSI-LD/CI/Prov/BE/003_10", "test_objective": "Check that you can create a batch of entities where two have the same id", - "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.7", + "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.6.7", "config_id": "", - "parent_release": "v1.3.1", + "parent_release": "v1.5.1", "clauses": [ "5.6.7" ], "pics_selection": "", - "keywords": [], + "keywords": [ + "Delete Entities" + ], "teardown": "None", "initial_condition": "with {\n the SUT containing an initial state\n}", "test_cases": [ diff --git a/doc/files/ContextInformation/Provision/004_07.json b/doc/files/ContextInformation/Provision/004_07.json index 170b1f2c..7aa231c0 100644 --- a/doc/files/ContextInformation/Provision/004_07.json +++ b/doc/files/ContextInformation/Provision/004_07.json @@ -1,14 +1,16 @@ { "tp_id": "TP/NGSI-LD/CI/Prov/BE/004_07", "test_objective": "Check that you can upsert a batch of entities where two have the same id", - "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.8", + "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.6.8", "config_id": "", - "parent_release": "v1.3.1", + "parent_release": "v1.5.1", "clauses": [ "5.6.8" ], "pics_selection": "", - "keywords": [], + "keywords": [ + "Delete Entities" + ], "teardown": "None", "initial_condition": "with {\n the SUT containing an initial state\n}", "test_cases": [ diff --git a/doc/files/ContextInformation/Provision/006_04.json b/doc/files/ContextInformation/Provision/006_04.json index b77f5437..c86a7e67 100644 --- a/doc/files/ContextInformation/Provision/006_04.json +++ b/doc/files/ContextInformation/Provision/006_04.json @@ -1,14 +1,16 @@ { "tp_id": "TP/NGSI-LD/CI/Prov/BE/006_04", "test_objective": "Check that you can delete a batch of entities with the same id", - "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.10", + "reference": "ETSI GS CIM 009 V1.5.1 [], clause 5.6.10", "config_id": "", - "parent_release": "v1.3.1", + "parent_release": "v1.5.1", "clauses": [ "5.6.10" ], "pics_selection": "", - "keywords": [], + "keywords": [ + "Setup Initial Entity" + ], "teardown": "None", "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing an initial Entity ${entity} \n with an id set to ${entityId} \n}", "test_cases": [ -- GitLab