Commit 0694ef87 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

feat: check 207 when appending attribute with noOverwrite and existing attribute

parent 572fbee7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -19,13 +19,13 @@ ${entity_payload_filename}= building-simple-attributes.jsonld
*** Test Cases ***    FILENAME    UPDATE_FRAGMENT_FILENAME    EXPECTED_STATUS
005_02_01 EntityWithExistingAttributes
    [Tags]    be-update    5_6_9
    building-simple-attributes.jsonld    fragmentEntities/empty-fragment.json    204
    building-simple-attributes.jsonld    fragmentEntities/empty-fragment.json    207
005_02_02 EntityWithNewAttribute
    [Tags]    be-update    5_6_9
    building-relationship.jsonld    fragmentEntities/locatedAt-fragment.json    204
005_02_03 EntityWithNewAndExistingAttribute
    [Tags]    be-update    5_6_9
    building-location-attribute.jsonld    fragmentEntities/location-fragment.json    204
    building-location-attribute.jsonld    fragmentEntities/location-fragment.json    207


*** Keywords ***
+15 −5
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that one can append entity attributes
Documentation       Check that one can append entity attributes with noOverwrite option

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
@@ -14,18 +14,20 @@ Test Template Append Attributes With Params
*** Variables ***
${vehicle_id_prefix}=               urn:ngsi-ld:Vehicle:
${filename}=                        vehicle-speed-two-datasetid.jsonld
${existing_attribute_name}=         https://ngsi-ld-test-suite/context#speed
${non_existing_attribute_name}=     https://uri.etsi.org/ngsi-ld/default-context/attribute_to_be_added


*** Test Cases ***    STATUS_CODE    FRAGMENT_FILENAME    EXPECTATION_FILENAME
010_04_01 Append entity attributes and ignore existing multi-attribute instance
    204    vehicle-attribute-to-add-fragment.jsonld    vehicle-speed-appended.jsonld
    207    vehicle-attribute-to-add-fragment.jsonld    vehicle-speed-appended.jsonld
010_04_02 Append entity attributes with a new multi-attribute instance
    204    vehicle-speed-different-datasetid-fragment.jsonld    vehicle-speed-different-datasetid.jsonld


*** Keywords ***
Append Attributes With Params
    [Documentation]    Check that one can append entity attributes
    [Documentation]    Check that one can append entity attributes with noOverwrite option
    [Tags]    ea-append    5_6_3
    [Arguments]    ${status_code}    ${fragment_filename}    ${expectation_filename}
    ${response}=    Append Entity Attributes With Parameters
@@ -34,6 +36,14 @@ Append Attributes With Params
    ...    ${CONTENT_TYPE_LD_JSON}
    ...    noOverwrite
    Check Response Status Code    ${status_code}    ${response.status_code}
    IF    ${status_code} == 207
        @{expected_successful_attributes_names}=    Create List    ${non_existing_attribute_name}
        @{expected_failed_attributes_names}=    Create List    ${existing_attribute_name}
        &{expected_update_result}=    Create Update Result
        ...    ${expected_successful_attributes_names}
        ...    ${expected_failed_attributes_names}
        Check Response Body Containing Update Result    ${expected_update_result}    ${response.json()}
    END

    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${response1}=    Retrieve Entity by Id
+13 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ class Checks:
                Checks.check_notificationparams,
            'Check Response Body Containing Batch Operation Result':
                Checks.check_response_body_containing_batch_operation_result,
            'Check Response Body Containing Update Result':
                Checks.check_response_body_containing_update_result,
            'Wait for notification':
                Checks.wait_for_notification,
            'Wait for no notification':
@@ -307,6 +309,10 @@ class Checks:
                'params': ['operation'],
                'position': [0]
            },
            'Check Response Body Containing Update Result': {
                'params': ['expected_update_result'],
                'position': [0]
            },
            'Should be Equal': {
                'params': ['expected_value', 'obtained_value'],
                'position': [0, 1]
@@ -1106,6 +1112,13 @@ class Checks:
        else:
            raise Exception(f'ERROR, Expected operation parameter but received: {kwargs}')

    @staticmethod
    def check_response_body_containing_update_result(kwargs: list) -> str:
        if "expected_update_result" in kwargs:
            return f"Response body containing update result set to '{kwargs['expected_update_result']}'"
        else:
            raise Exception(f'ERROR, Expected expected_update_result parameter but received: {kwargs}')

    @staticmethod
    def check_response_body_content(kwargs: list) -> str:
        expected_parameters = ['expectation_filename', 'response_body', 'additional_ignored_path']
+9 −7
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/Prov/BE/005_02",
  "test_objective": "Check that you can update a batch of entities with noOverwrite option",
  "test_objective": "Check that one can update a batch of entities with noOverwrite option",
  "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.9",
  "config_id": "",
  "parent_release": "v1.3.1",
@@ -19,7 +19,7 @@
    {
      "name": "005_02_01 EntityWithExistingAttributes",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/005_02_01",
      "doc": "Check that you can update a batch of entities with noOverwrite option",
      "doc": "Check that one can update a batch of entities with noOverwrite option",
      "tags": [
        "5_6_9",
        "be-update"
@@ -27,7 +27,7 @@
      "setup": "Setup Initial Entities",
      "teardown": "Delete Initial Entities",
      "template": "Batch Update Entity With NoOverwrite Option Scenarios",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Update Entities with Response Status Code set to 204     and\n        Query Entities with Updated Entities set to '${updated_entities}' valid entities\n}",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Update Entities with Response Status Code set to 207     and\n        Query Entities with Updated Entities set to '${updated_entities}' valid entities\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entityOperations/update?${params_as_string}'\n        method set to 'POST'\n        Request batch update operation over entity from filename '@{entities_to_be_updated}' with overwrite_option set to '${EMPTY}' and Content-Type set to 'application/ld+json'\n}",
      "http_verb": "POST",
      "endpoint": "entityOperations/update?${params_as_string}"
@@ -35,7 +35,7 @@
    {
      "name": "005_02_02 EntityWithNewAttribute",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/005_02_02",
      "doc": "Check that you can update a batch of entities with noOverwrite option",
      "doc": "Check that one can update a batch of entities with noOverwrite option",
      "tags": [
        "5_6_9",
        "be-update"
@@ -51,7 +51,7 @@
    {
      "name": "005_02_03 EntityWithNewAndExistingAttribute",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/BE/005_02_03",
      "doc": "Check that you can update a batch of entities with noOverwrite option",
      "doc": "Check that one can update a batch of entities with noOverwrite option",
      "tags": [
        "5_6_9",
        "be-update"
@@ -59,13 +59,15 @@
      "setup": "Setup Initial Entities",
      "teardown": "Delete Initial Entities",
      "template": "Batch Update Entity With NoOverwrite Option Scenarios",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Update Entities with Response Status Code set to 204     and\n        Query Entities with Updated Entities set to '${updated_entities}' valid entities\n}",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Batch Update Entities with Response Status Code set to 207     and\n        Query Entities with Updated Entities set to '${updated_entities}' valid entities\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entityOperations/update?${params_as_string}'\n        method set to 'POST'\n        Request batch update operation over entity from filename '@{entities_to_be_updated}' with overwrite_option set to '${EMPTY}' and Content-Type set to 'application/ld+json'\n}",
      "http_verb": "POST",
      "endpoint": "entityOperations/update?${params_as_string}"
    }
  ],
  "permutations": [],
  "permutations": [
    "then"
  ],
  "robotpath": "ContextInformation/Provision/BatchEntities/UpdateBatchOfEntities",
  "robotfile": "005_02"
}
 No newline at end of file
+6 −5
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/Prov/EA/010_04",
  "test_objective": "Check that you can append entity attributes",
  "test_objective": "Check that one can append entity attributes with noOverwrite option",
  "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.6.3",
  "config_id": "",
  "parent_release": "v1.3.1",
@@ -19,7 +19,7 @@
    {
      "name": "010_04_01 Append entity attributes and ignore existing multi-attribute instance",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/010_04_01",
      "doc": "Check that you can append entity attributes",
      "doc": "Check that one can append entity attributes with noOverwrite option",
      "tags": [
        "ea-append",
        "5_6_3"
@@ -27,7 +27,7 @@
      "setup": "Create Initial Entity",
      "teardown": "Delete Initial Entity",
      "template": "Append Attributes With Params",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Append Entity Attributes With Parameters with Response Status Code set to 204     and\n        Retrieve Entity by Id with Check Updated Entity and\n            Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n            Query Parameter: 'response_body' set to 'response1.json()' and\n            Query Parameter: 'ignored_keys' set to 'ignored_attributes'\n}",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Append Entity Attributes With Parameters with Response Status Code set to 207     and\n        Append Entity Attributes With Parameters with Response body containing update result set to '${expected_update_result}'     and\n        Retrieve Entity by Id with Check Updated Entity and\n            Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n            Query Parameter: 'response_body' set to 'response1.json()' and\n            Query Parameter: 'ignored_keys' set to 'ignored_attributes'\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/{id}/attrs?options=${options}'\n        method set to 'POST'\n        Append entity attributes with parameters: and\n    Query Parameter: id set to '${entity_id}' and\n    Query Parameter: fragment_filename set to 'vehicle-attribute-to-add-fragment.jsonld' and\n    Query Parameter: content_type set to 'application/ld+json' and\n    Query Parameter: options set to 'noOverwrite'\n}",
      "http_verb": "POST",
      "endpoint": "entities/{id}/attrs?options=${options}"
@@ -35,7 +35,7 @@
    {
      "name": "010_04_02 Append entity attributes with a new multi-attribute instance",
      "permutation_tp_id": "TP/NGSI-LD/CI/Prov/EA/010_04_02",
      "doc": "Check that you can append entity attributes",
      "doc": "Check that one can append entity attributes with noOverwrite option",
      "tags": [
        "ea-append",
        "5_6_3"
@@ -43,13 +43,14 @@
      "setup": "Create Initial Entity",
      "teardown": "Delete Initial Entity",
      "template": "Append Attributes With Params",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Append Entity Attributes With Parameters with Response Status Code set to 204     and\n        Retrieve Entity by Id with Check Updated Entity and\n            Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n            Query Parameter: 'response_body' set to 'response1.json()' and\n            Query Parameter: 'ignored_keys' set to 'ignored_attributes'\n}",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Append Entity Attributes With Parameters with Response Status Code set to 204     and\n        Append Entity Attributes With Parameters with Response body containing update result set to '${expected_update_result}'     and\n        Retrieve Entity by Id with Check Updated Entity and\n            Query Parameter: 'updated_resource' set to 'entity_expectation_payload' and\n            Query Parameter: 'response_body' set to 'response1.json()' and\n            Query Parameter: 'ignored_keys' set to 'ignored_attributes'\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/{id}/attrs?options=${options}'\n        method set to 'POST'\n        Append entity attributes with parameters: and\n    Query Parameter: id set to '${entity_id}' and\n    Query Parameter: fragment_filename set to 'vehicle-speed-different-datasetid-fragment.jsonld' and\n    Query Parameter: content_type set to 'application/ld+json' and\n    Query Parameter: options set to 'noOverwrite'\n}",
      "http_verb": "POST",
      "endpoint": "entities/{id}/attrs?options=${options}"
    }
  ],
  "permutations": [
    "then",
    "when"
  ],
  "robotpath": "ContextInformation/Provision/EntityAttributes/AppendEntityAttributes",
Loading