From e42ab048d701d4d5f336fb8048e6a023130c4e24 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Mon, 11 Jan 2021 18:22:19 +0000 Subject: [PATCH] added update entity tests --- .../Provision/EntityAttributes/001.robot | 12 +++--- .../Provision/EntityAttributes/004.robot | 32 +++++++++++++++ .../Provision/EntityAttributes/005.robot | 33 +++++++++++++++ .../Provision/EntityAttributes/005_03.robot | 26 ++++++++++++ .../Provision/EntityAttributes/006.robot | 23 +++++++++++ ...id-attributes-sample-expectation-01.jsonld | 0 ...id-attributes-sample-expectation-03.jsonld | 31 ++++++++++++++ ...id-attributes-sample-expectation-04.jsonld | 0 ...ragment-different-datasetid-sample.jsonld} | 0 ...cle-fragment-same-datasetid-sample.jsonld} | 0 ...-two-datasetid-attributes-sample-01.jsonld | 23 +++++++++++ ...-two-datasetid-attributes-sample-02.jsonld | 25 ++++++++++++ ...-two-datasetid-attributes-sample-03.jsonld | 25 ++++++++++++ ...-two-datasetid-attributes-sample-04.jsonld | 25 ++++++++++++ ...cle-two-datasetid-attributes-sample.jsonld | 40 +++++++++++++++++++ resources/ApiUtils.resource | 28 ++++++++++--- resources/AssertionUtils.resource | 8 +++- 17 files changed, 319 insertions(+), 12 deletions(-) create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot create mode 100644 TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot create mode 100644 data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-01.jsonld create mode 100644 data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-03.jsonld create mode 100644 data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-04.jsonld rename data/entities/fragmentEntities/{vehicle-fragment-datasetid-sample-01-02.jsonld => vehicle-fragment-different-datasetid-sample.jsonld} (100%) rename data/entities/fragmentEntities/{vehicle-fragment-datasetid-sample-03-04.jsonld => vehicle-fragment-same-datasetid-sample.jsonld} (100%) create mode 100644 data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-01.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-02.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-03.jsonld create mode 100644 data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-04.jsonld create mode 100644 data/entities/vehicle-two-datasetid-attributes-sample.jsonld diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot index 8a254372..bcecbd8e 100644 --- a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/001.robot @@ -9,11 +9,11 @@ Test Template Append Attributes *** Variable *** ${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: -*** Test Cases *** STATUS_CODE OVERWRITE FILENAME FRAGMENT_FILENAME EXPECTATION_FILENAME -001_01_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-datasetid-sample-01-02.jsonld vehicle-attributes-sample-append-expectation-01.jsonld -001_02_Append entity attributes 207 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-datasetid-sample-01-02.jsonld vehicle-attributes-sample-append-expectation-02.jsonld -001_03_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-datasetid-sample-03-04.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld -001_04_Append entity attributes 204 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-datasetid-sample-03-04.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld +*** Test Cases *** STATUS_CODE OVERWRITE FILENAME FRAGMENT_FILENAME EXPECTATION_FILENAME +001_01_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-01.jsonld +001_02_Append entity attributes 207 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-same-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-02.jsonld +001_03_Append entity attributes 204 ${EMPTY} vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld +001_04_Append entity attributes 204 noOverwrite vehicle-datasetid-attributes-sample.jsonld vehicle-fragment-different-datasetid-sample.jsonld vehicle-attributes-sample-append-expectation-03-04.jsonld *** Keywords *** Append Attributes @@ -27,6 +27,6 @@ Append Attributes ${response}= Append Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${overwrite} Check Response Status Code ${status_code} ${response['status']} - Check Response Body Containing Entity element ${expectation_filename} ${entity_id} ${response['body']} + Check Response Body Content ${expectation_filename} ${response['body']} [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot new file mode 100644 index 00000000..be96764a --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/004.robot @@ -0,0 +1,32 @@ +*** Settings *** +Documentation Check that you can update entity attributes +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Update Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: + +*** Test Cases *** STATUS_CODE FILENAME FRAGMENT_FILENAME EXPECTATION_FILENAME +004_01_Check that you can update existing attributes with no datasetId 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-01.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld +004_02_Check that you can update existing attributes with the datasetId 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-02.jsonld vehicle-two-datasetid-attributes-sample-expectation-01.jsonld +004_03_Check that you can update only some attributes while others failed 207 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-03.jsonld vehicle-two-datasetid-attributes-sample-expectation-03.jsonld +004_04_Check that you cannot change the type of the attribute 204 vehicle-two-datasetid-attributes-sample.jsonld vehicle-two-datasetid-attributes-sample-04.jsonld vehicle-two-datasetid-attributes-sample-expectation-04.jsonld + +*** Keywords *** +Update Attributes + [Arguments] ${status_code} ${filename} ${fragment_filename} ${expectation_filename} + [Documentation] Check that you can update entity attributes + [Tags] mandatory failing + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + Check Response Body Content ${expectation_filename} ${response['body']} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005.robot new file mode 100644 index 00000000..c3ca676d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Check that you cannot update entity attributes with invalid/missing id or invalid request body +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +Test Template Update Attributes + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-two-datasetid-attributes-sample.jsonld +${fragment_filename}= vehicle-two-datasetid-attributes-sample-01.jsonld + +*** Test Cases *** STATUS_CODE ENTITY_INVALID_ID +005_01_Update an attribute if the Entity Id is not present 400 ${EMPTY} +005_02_Update an attribute if the Entity Id is not a valid URI 400 thisisaninvaliduri + +*** Keywords *** +Update Attributes + [Arguments] ${status_code} ${entity_invalid_id} + [Documentation] Check that you cannot update entity attributes with invalid/missing id or invalid request body + [Tags] mandatory failing + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Update Entity Attributes ${entity_invalid_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code ${status_code} ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot new file mode 100644 index 00000000..c6e1a0a4 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/005_03.robot @@ -0,0 +1,26 @@ +*** Settings *** +Documentation Check that you cannot update an attribute if the entity fragment is invalid +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${filename}= vehicle-datasetid-attributes-sample.jsonld +${fragment_filename}= invalid-vehicle-fragment-datasetid-sample.jsonld + +*** Test Cases *** +Update entity attributes with invalid entity fragments + [Documentation] Check that you cannot update an attribute if the entity fragment is invalid + [Tags] mandatory failing + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${request} ${response}= Create Entity Selecting Content Type ${filename} ${entity_id} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response['status']} + + ${response}= Update Entity Attributes Using Session ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${EMPTY} + Check Response Status Code 400 ${response} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_BAD_REQUEST_DATA} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot new file mode 100644 index 00000000..d372e29d --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Provision/EntityAttributes/006.robot @@ -0,0 +1,23 @@ +*** Settings *** +Documentation Check that you cannot update entity attributes if the entity id or attributes are not known to the system +Resource ${EXECDIR}/resources/ApiUtils.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource + +*** Variable *** +${vehicle_id_prefix}= urn:ngsi-ld:Vehicle: +${fragment_filename}= vehicle-two-datasetid-attributes-sample-01.jsonld + +*** Test Cases *** +003_Update entity attributes when the entity id is not known to the system + [Documentation] Check that you cannot update entity attributes if the entity id or attributes are not known to the system + [Tags] mandatory failing + + ${entity_id}= Generate Random Entity Id ${vehicle_id_prefix} + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 404 ${response['status']} + Check Response Body Containing ProblemDetails Element Containing Type Element set to ${response} ${ERROR_TYPE_RESOURCE_NOT_FOUND} + Check Response Body Containing ProblemDetails Element Containing Title Element ${response} + +*** Keywords *** + [Teardown] Delete Entity by Id Returning Response ${entity_id} \ No newline at end of file diff --git a/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-01.jsonld b/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-01.jsonld new file mode 100644 index 00000000..e69de29b diff --git a/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-03.jsonld b/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-03.jsonld new file mode 100644 index 00000000..23254a3e --- /dev/null +++ b/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-03.jsonld @@ -0,0 +1,31 @@ +{ + "https://uri.fiware.org/ns/data-models#speed": [ + { + "https://uri.etsi.org/ngsi-ld/datasetId": [ + { + "@id": "urn:ngsi-ld:Property:speedometerA4567-speed" + } + ], + "https://uri.fiware.org/ns/data-models#source": [ + { + "@type": [ + "https://uri.etsi.org/ngsi-ld/Property" + ], + "https://uri.etsi.org/ngsi-ld/hasValue": [ + { + "@value": "Speedometer" + } + ] + } + ], + "@type": [ + "https://uri.etsi.org/ngsi-ld/Property" + ], + "https://uri.etsi.org/ngsi-ld/hasValue": [ + { + "@value": 99 + } + ] + } + ] +} \ No newline at end of file diff --git a/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-04.jsonld b/data/entities/expectations/vehicle-two-datasetid-attributes-sample-expectation-04.jsonld new file mode 100644 index 00000000..e69de29b diff --git a/data/entities/fragmentEntities/vehicle-fragment-datasetid-sample-01-02.jsonld b/data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld similarity index 100% rename from data/entities/fragmentEntities/vehicle-fragment-datasetid-sample-01-02.jsonld rename to data/entities/fragmentEntities/vehicle-fragment-different-datasetid-sample.jsonld diff --git a/data/entities/fragmentEntities/vehicle-fragment-datasetid-sample-03-04.jsonld b/data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld similarity index 100% rename from data/entities/fragmentEntities/vehicle-fragment-datasetid-sample-03-04.jsonld rename to data/entities/fragmentEntities/vehicle-fragment-same-datasetid-sample.jsonld diff --git a/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-01.jsonld b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-01.jsonld new file mode 100644 index 00000000..115393ad --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-01.jsonld @@ -0,0 +1,23 @@ +{ + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:JohnDoe" + } + }, + "speed": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + } + }, + "@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/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-02.jsonld b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-02.jsonld new file mode 100644 index 00000000..5a0ece28 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-02.jsonld @@ -0,0 +1,25 @@ +{ + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:JohnDoe" + }, + "datasetId": "urn:ngsi-ld:Relationship:parked12345" + }, + "speed": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "@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/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-03.jsonld b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-03.jsonld new file mode 100644 index 00000000..b18c7a96 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-03.jsonld @@ -0,0 +1,25 @@ +{ + "isParked2": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:JohnDoe" + }, + "datasetId": "urn:ngsi-ld:Relationship:parked12345" + }, + "speed": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "@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/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-04.jsonld b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-04.jsonld new file mode 100644 index 00000000..a906bcc3 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-two-datasetid-attributes-sample-04.jsonld @@ -0,0 +1,25 @@ +{ + "isParked2": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:JohnDoe" + }, + "datasetId": "urn:ngsi-ld:Relationship:parked12345" + }, + "speed2": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + "@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/data/entities/vehicle-two-datasetid-attributes-sample.jsonld b/data/entities/vehicle-two-datasetid-attributes-sample.jsonld new file mode 100644 index 00000000..7e83ea23 --- /dev/null +++ b/data/entities/vehicle-two-datasetid-attributes-sample.jsonld @@ -0,0 +1,40 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "brandName": { + "type": "Property", + "value": "Mercedes" + }, + "isParked": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown1", + "observedAt": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + }, + "datasetId": "urn:ngsi-ld:Relationship:parked12345" + }, + "speed": [{ + "type": "Property", + "value": 55, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed" + }, + { + "type": "Property", + "value": 54.5, + "source": { + "type": "Property", + "value": "GPS" + }, + "datasetId": "urn:ngsi-ld:Property:gpsBxyz123-speed" + }], + "@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 6ead6b36..facc21d5 100755 --- a/resources/ApiUtils.resource +++ b/resources/ApiUtils.resource @@ -20,10 +20,10 @@ ${TEMPORAL_ENTITY_OPERATIONS_ENDPOINT_PATH} temporal/entityOperations ${CONTENT_TYPE_JSON} application/json ${CONTENT_TYPE_LD_JSON} application/ld+json -${ERROR_TYPE_BAD_REQUEST_DATA} http://uri.etsi.org/ngsi-ld/errors/BadRequestData -${ERROR_TYPE_INVALID_REQUEST} http://uri.etsi.org/ngsi-ld/errors/InvalidRequest -${ERROR_TYPE_RESOURCE_NOT_FOUND} http://uri.etsi.org/ngsi-ld/errors/ResourceNotFound -${ERROR_TYPE_ALREADY_EXISTS} http://uri.etsi.org/ngsi-ld/errors/AlreadyExists +${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_RESOURCE_NOT_FOUND} https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound +${ERROR_TYPE_ALREADY_EXISTS} https://uri.etsi.org/ngsi-ld/errors/AlreadyExists ${response} @@ -157,10 +157,28 @@ Append Entity Attributes Using Session ${file_content}= Get File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} Create Session OneRequest ${url} &{headers}= Create Dictionary Content-Type=${content_type} - ${response}= POST On Session OneRequest ${ENTITIES_ENDPOINT_PATH}${id}/attrs params=options=${options} data=${file_content} headers=${headers} expected_status=any + ${response}= POST On Session OneRequest ${ENTITIES_ENDPOINT_PATH}${id}/attrs/ params=options=${options} data=${file_content} headers=${headers} expected_status=any Output ${response.json()} [return] ${response} +Update Entity Attributes Using Session + [Arguments] ${id} ${filename} ${content_type} ${options} + ${file_content}= Get File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} + Create Session OneRequest ${url} + &{headers}= Create Dictionary Content-Type=${content_type} + ${response}= PATCH On Session OneRequest ${ENTITIES_ENDPOINT_PATH}${id}/attrs/ data=${file_content} headers=${headers} expected_status=any + Output ${response.json()} + [return] ${response} + +Update Entity Attributes + [Arguments] ${id} ${fragment_filename} ${content_type} + &{headers}= Create Dictionary Content-Type=${content_type} + ${fragment_payload}= Load Json From File ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename} + ${response}= PATCH ${ENTITIES_ENDPOINT_PATH}${id}/attrs/ body=${fragment_payload} headers=${headers} + Output request + Output response + [return] ${response} + Create Entity [Arguments] ${filename} ${entity_id} ${entity_payload}= Load Json From File ${EXECDIR}/data/entities/${filename} diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 6db6f83a..e1ee2db9 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -27,9 +27,15 @@ 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 Body Content + [Arguments] ${expectation_filename} ${response_body} + ${entity_payload}= Load Json From File ${EXECDIR}/data/entities/expectations/${expectation_filename} + ${comparaison_result}= Compare Dictionaries Ignoring Keys ${response_body} ${entity_payload} ${instance_id_regex_expr} + Should Be True ${comparaison_result} msg=Entity Comparaison Failed + Check Response Headers Containing URI set to [Arguments] ${expected_path} ${expected_entity_id} ${response} - Should Be Equal ${expected_path}${expected_entity_id} ${response['headers']['location']} ignore_order=True + 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} -- GitLab