Commit 1b8cdbda authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'feature/add-entity-type-selection-language-tests' into 'develop'

feat: add test cases for entity type selection language

See merge request !130
parents 1239de43 2c1e7648
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Query entities with Entity Type Selection Language.

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Suite Setup         Setup Initial Entities
Suite Teardown      Delete Initial Entities
Test Template       Query entities using Entity Type Selection Language


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:MultiTypes:
${first_entity_filename}                building-simple-attributes-sample.jsonld
${second_entity_filename}               building-with-different-type-sample.jsonld
${third_entity_filename}                building-with-two-types-sample.jsonld
${building_entity_type}                 Building
${parking_entity_type}                  Parking
${tourist_destination_entity_type}      TouristDestination


*** Test Cases ***    ENTITY_TYPES_SELECTION    EXPECTED_ENTITIES_IDS
019_08_01 query with one type    ${building_entity_type}    ${first_entity_id},${third_entity_id}
019_08_02 query with the AND operator    (${building_entity_type};${tourist_destination_entity_type})    ${third_entity_id}
019_08_03 query with the OR operator    ${building_entity_type},${parking_entity_type}    ${first_entity_id},${second_entity_id},${third_entity_id}
019_08_04 different query with the OR operator    ${parking_entity_type},${tourist_destination_entity_type}    ${second_entity_id},${third_entity_id}
019_08_05 query with two operators    (${building_entity_type};${parking_entity_type}),${tourist_destination_entity_type}    ${third_entity_id}


*** Keywords ***
Query entities using Entity Type Selection Language
    [Documentation]    Query entities with Entity Type Selection Language.
    [Tags]    e-query    4_17    5_7_2    since_v1.5.1
    [Arguments]    ${entity_types_selection}    ${expected_entities_ids}

    ${entities_ids}=    Split String    ${expected_entities_ids}    ,
    @{entities_ids_list}=    Create List    ${entities_ids}
    ${response}=    Query Entities
    ...    entity_types=${entity_types_selection}
    ...    context=${ngsild_test_suite_context}

    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Entities URIS set to
    ...    @{entities_ids_list}
    ...    ${response.json()}

Setup Initial Entities
    ${first_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${first_entity_id}
    ${create_response1}=    Create Entity Selecting Content Type
    ...    ${first_entity_filename}
    ...    ${first_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response1.status_code}
    ${second_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${second_entity_id}
    ${create_response2}=    Create Entity Selecting Content Type
    ...    ${second_entity_filename}
    ...    ${second_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response2.status_code}
    ${third_entity_id}=    Generate Random Entity Id    ${entity_id_prefix}
    Set Suite Variable    ${third_entity_id}
    ${create_response3}=    Create Entity Selecting Content Type
    ...    ${third_entity_filename}
    ...    ${third_entity_id}
    ...    ${CONTENT_TYPE_LD_JSON}
    Check Response Status Code    201    ${create_response3.status_code}

Delete Initial Entities
    Delete Entity by Id    ${first_entity_id}
    Delete Entity by Id    ${second_entity_id}
    Delete Entity by Id    ${third_entity_id}
+7 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:MultiTypes:randomUUID",
    "type": ["Parking" ],
    "@context": [
        "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
    ]
}
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
{
    "id": "urn:ngsi-ld:MultiTypes:randomUUID",
    "type": ["Building", "TouristDestination" ],
    "@context": [
        "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
    ]
}
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ class Checks:
                Checks.check_response_status_code,
            'Check Response Body Containing Array Of URIs set to':
                Checks.check_response_body_containing_array_of_uris_set_to,
            'Check Response Body Containing Entities URIS set to' :
                 Checks.check_response_body_containing_entities_uris_set_to,
            'Check Created Resources Set To':
                Checks.check_created_resources_set_to,
            'Check Response Headers Containing Content-Type set to':
@@ -129,6 +131,10 @@ class Checks:
                'params': ['expected_entities_ids', 'response_body'],
                'position': [0, 1]
            },
            'Check Response Body Containing Entities URIS set to': {
                'params': ['expected_entities_ids', 'response_body'],
                'position': [0, 1]
            },
            'Check Response Body Containing ProblemDetails Element Containing Type Element set to': {
                'params': ['type'],
                'position': [1]
@@ -439,6 +445,10 @@ class Checks:
    def check_response_body_containing_array_of_uris_set_to(kwargs: list) -> str:
        return 'Response Body set to an array of created entities ids'

    @staticmethod
    def check_response_body_containing_entities_uris_set_to(kwargs: list) -> str:
        return 'Response Body contains entities ids'

    @staticmethod
    def check_created_resources_set_to(kwargs: list) -> str:
        return 'Created resources set to ${entities}'
@@ -967,6 +977,7 @@ if __name__ == "__main__":
    print(data.get_checks(checks='Check Response Status Code',
                          status_code=201))
    print(data.get_checks(checks='Check Response Body Containing Array Of URIs set to'))
    print(data.get_checks(checks='Check Response Body Containing Entities URIS set to'))
    print(data.get_checks(checks='Check Created Resources Set To'))
    print(data.get_checks(checks='Check Response Headers Containing Content-Type set to',
                          content_type='application/json'))
+114 −0
Original line number Diff line number Diff line
{
  "tp_id": "TP/NGSI-LD/CI/Cons/E/019_08",
  "test_objective": "Query entities with Entity Type Selection Language.",
  "reference": "ETSI GS CIM 009 V1.5.1 [], clauses 4.17, 5.7.2",
  "config_id": "",
  "parent_release": "v1.5.1",
  "clauses": [
    "4.17",
    "5.7.2"
  ],
  "pics_selection": "",
  "keywords": [
    "Query entities using Entity Type Selection Language",
    "Setup Initial Entities",
    "Delete Initial Entities"
  ],
  "teardown": "Delete Initial Entities",
  "initial_condition": "with {\n   the SUT containing an initial state\n}",
  "test_cases": [
    {
      "name": "019_08_01 query with one type",
      "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_01",
      "doc": "Query entities with Entity Type Selection Language.",
      "tags": [
        "e-query",
        "4_17",
        "5_7_2",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": null,
      "template": "Query entities using Entity Type Selection Language",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Query Entities with Response Status Code set to 200     and\n        Query Entities with Response Body contains entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/'\n        method set to 'GET'\n        Get Entities Request: and\n    Query Parameter: entity_types set to '${entity_types_selection}' and\n    Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
      "http_verb": "GET",
      "endpoint": "entities/"
    },
    {
      "name": "019_08_02 query with the AND operator",
      "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_02",
      "doc": "Query entities with Entity Type Selection Language.",
      "tags": [
        "e-query",
        "4_17",
        "5_7_2",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": null,
      "template": "Query entities using Entity Type Selection Language",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Query Entities with Response Status Code set to 200     and\n        Query Entities with Response Body contains entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/'\n        method set to 'GET'\n        Get Entities Request: and\n    Query Parameter: entity_types set to '${entity_types_selection}' and\n    Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
      "http_verb": "GET",
      "endpoint": "entities/"
    },
    {
      "name": "019_08_03 query with the OR operator",
      "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_03",
      "doc": "Query entities with Entity Type Selection Language.",
      "tags": [
        "e-query",
        "4_17",
        "5_7_2",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": null,
      "template": "Query entities using Entity Type Selection Language",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Query Entities with Response Status Code set to 200     and\n        Query Entities with Response Body contains entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/'\n        method set to 'GET'\n        Get Entities Request: and\n    Query Parameter: entity_types set to '${entity_types_selection}' and\n    Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
      "http_verb": "GET",
      "endpoint": "entities/"
    },
    {
      "name": "019_08_04 different query with the OR operator",
      "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_04",
      "doc": "Query entities with Entity Type Selection Language.",
      "tags": [
        "e-query",
        "4_17",
        "5_7_2",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": null,
      "template": "Query entities using Entity Type Selection Language",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Query Entities with Response Status Code set to 200     and\n        Query Entities with Response Body contains entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/'\n        method set to 'GET'\n        Get Entities Request: and\n    Query Parameter: entity_types set to '${entity_types_selection}' and\n    Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
      "http_verb": "GET",
      "endpoint": "entities/"
    },
    {
      "name": "019_08_05 query with two operators",
      "permutation_tp_id": "TP/NGSI-LD/CI/Cons/E/019_08_05",
      "doc": "Query entities with Entity Type Selection Language.",
      "tags": [
        "e-query",
        "4_17",
        "5_7_2",
        "since_v1.5.1"
      ],
      "setup": null,
      "teardown": null,
      "template": "Query entities using Entity Type Selection Language",
      "then": "then {\n    the SUT sends a valid Response for the operations:\n        Query Entities with Response Status Code set to 200     and\n        Query Entities with Response Body contains entities ids\n}",
      "when": "when {\n    the SUT receives a Request from the client containing:\n        URL set to '/ngsi-ld/v1/entities/'\n        method set to 'GET'\n        Get Entities Request: and\n    Query Parameter: entity_types set to '${entity_types_selection}' and\n    Query Parameter: Link set to '<$https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld>; rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\"'\n}",
      "http_verb": "GET",
      "endpoint": "entities/"
    }
  ],
  "permutations": [],
  "robotpath": "ContextInformation/Consumption/Entity/QueryEntities",
  "robotfile": "019_08"
}
 No newline at end of file
Loading