Commit 3e62fd28 authored by Benoit Orihuela's avatar Benoit Orihuela
Browse files

Merge branch 'feature/add-scope-tests' into 'develop'

feat: add scope and scopeQ tests

See merge request cim/ngsi-ld-test-suite!123
parents 54ae85ef 5b7e3a19
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can query several entities based on scopes

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 Entities
Test Template       Query several entities based on scopes


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:
${entity_one_scope}=        building-minimal-with-one-scope.json
${entity_many_scopes}=      building-minimal-with-many-scopes.json
${entity_type}=             https://ngsi-ld-test-suite/context#Building


*** Test Cases ***    SCOPEQ    EXPECTED_COUNT
019_01_06 QueryWithFullScope
    [Tags]    e-query    4_19    since_v1.5.1
    /Madrid/Gardens/ParqueNorte    ${2}
019_01_06 QueryWithPlusMatching
    [Tags]    e-query    4_19    since_v1.5.1
    /Madrid/+/ParqueNorte    ${2}
019_01_06 QueryWithHashMatching
    [Tags]    e-query    4_19    since_v1.5.1
    /CompanyA/#    ${1}
019_01_06 QueryNonEmptyScope
    [Tags]    e-query    4_19    since_v1.5.1
    /#    ${2}
019_01_06 QueryWithAndScope
    [Tags]    e-query    4_19    since_v1.5.1
    /Madrid/Gardens/ParqueNorte;/CompanyA/OrganizationB/UnitC    ${1}
019_01_06 QueryWithOrScope
    [Tags]    e-query    4_19    since_v1.5.1
    /Madrid/Gardens/ParqueNorte,/CompanyA/OrganizationB/UnitC    ${2}


*** Keywords ***
Query several entities based on scopes
    [Documentation]    Check that you can query several entities based on scopes
    [Arguments]    ${scopeq}    ${expected_count}
    ${response}=    Query Entities
    ...    scopeq=${scopeq}
    ...    entity_types=${entity_type}
    Check Response Status Code    200    ${response.status_code}
    Check Response Body Containing Number Of Entities    ${entity_type}    ${expected_count}    ${response.json()}

Setup Initial Entities
    ${entity_one_scope_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${entity_one_scope_id}
    Create Entity Selecting Content Type
    ...    ${entity_one_scope}
    ...    ${entity_one_scope_id}
    ...    ${CONTENT_TYPE_JSON}
    ...    ${ngsild_test_suite_context}
    ${entity_many_scopes_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Suite Variable    ${entity_many_scopes_id}
    Create Entity Selecting Content Type
    ...    ${entity_many_scopes}
    ...    ${entity_many_scopes_id}
    ...    ${CONTENT_TYPE_JSON}
    ...    ${ngsild_test_suite_context}

Delete Entities
    Delete Entity by Id    ${entity_one_scope_id}
    Delete Entity by Id    ${entity_many_scopes_id}
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ ${building_id_prefix}= urn:ngsi-ld:Building:
*** Test Cases ***    FILENAME    CONTENT_TYPE
001_01_01 MinimalEntity
    [Tags]    e-create    5_6_1
    building-minimal-without-context-sample.jsonld    application/json
    building-minimal-sample.json    application/json
001_01_02 EntityWithSimpleProperties
    [Tags]    e-create    5_6_1
    building-simple-attributes-sample.jsonld    application/ld+json
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ Test Template Create Entity With Invalid Request Scenarios
    empty-sample.jsonld    ${ERROR_TYPE_INVALID_REQUEST}
001_02_03 EntityWithNoContext
    [Tags]    e-create    5_6_1
    building-minimal-without-context-sample.jsonld    ${ERROR_TYPE_BAD_REQUEST_DATA}
    building-minimal-sample.json    ${ERROR_TYPE_BAD_REQUEST_DATA}


*** Keywords ***
+43 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can create an entity with one or more scopes

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 Initial Entity
Test Template       Create Entity Scenarios


*** Variables ***
${building_id_prefix}=      urn:ngsi-ld:Building:


*** Test Cases ***    FILENAME    CONTENT_TYPE
001_11_01 EntityWithOneScope
    [Tags]    e-create    4_18    since_v1.5.1
    building-minimal-with-one-scope.json    application/json
001_11_02 EntityWithManyScopes
    [Tags]    e-create    4_18    since_v1.5.1
    building-minimal-with-many-scopes.json    application/json


*** Keywords ***
Create Entity Scenarios
    [Documentation]    Check that you can create an entity with one or more scopes
    [Arguments]    ${filename}    ${content_type}
    ${entity_id}=    Generate Random Entity Id    ${building_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${content_type}
    Check Response Status Code    201    ${response.status_code}
    Check Response Headers Containing URI set to    ${entity_id}    ${response.headers}
    ${created_entity}=    Load Test Sample    entities/${filename}    ${entity_id}
    ${response1}=    Retrieve Entity by Id    ${entity_id}    ${content_type}
    Check Created Resource Set To    ${created_entity}    ${response1.json()}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
+66 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Check that you can append a scope to an entity

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

Test Setup          Create Initial Entity
Test Teardown       Delete Initial Entity


*** Variables ***
${vehicle_id_prefix}=           urn:ngsi-ld:Vehicle:
${filename}=                    building-minimal-with-one-scope.json
${scope_fragment_filename}=     one-scope-fragment.json


*** Test Cases ***
010_07_01 Append scope to an entity with overwrite enabled
    [Documentation]    Check that scope is replaced if overwrite is enabled
    [Tags]    ea-append    5_6_3    4_18    since_v1.5.1
    ${response}=    Append Entity Attributes
    ...    ${entity_id}
    ...    ${scope_fragment_filename}
    ...    ${CONTENT_TYPE_JSON}
    Check Response Status Code    204    ${response.status_code}
    ${expectation_filename}=    Set Variable    building-minimal-with-one-scope-expectation.json
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${response}=    Retrieve Entity by Id
    ...    ${entity_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}

010_07_01 Append scope to an entity with overwrite disabled
    [Documentation]    Check that scope is appended if overwrite is disabled
    [Tags]    ea-append    5_6_3    4_18    since_v1.5.1
    ${response}=    Append Entity Attributes With Parameters
    ...    ${entity_id}
    ...    ${scope_fragment_filename}
    ...    ${CONTENT_TYPE_JSON}
    ...    noOverwrite
    Check Response Status Code    204    ${response.status_code}
    ${expectation_filename}=    Set Variable    building-minimal-with-two-scopes-expectation.json
    ${entity_expectation_payload}=    Load Test Sample    entities/expectations/${expectation_filename}    ${entity_id}
    ${response}=    Retrieve Entity by Id
    ...    ${entity_id}
    ...    accept=${CONTENT_TYPE_JSON}
    ...    context=${ngsild_test_suite_context}
    Check Updated Resource Set To    ${entity_expectation_payload}    ${response.json()}


*** Keywords ***
Create Initial Entity
    ${entity_id}=    Generate Random Entity Id    ${vehicle_id_prefix}
    Set Test Variable    ${entity_id}
    ${response}=    Create Entity Selecting Content Type
    ...    ${filename}
    ...    ${entity_id}
    ...    ${CONTENT_TYPE_JSON}
    ...    ${ngsild_test_suite_context}
    Check Response Status Code    201    ${response.status_code}

Delete Initial Entity
    Delete Entity by Id    ${entity_id}
Loading