Commit f20410a1 authored by Benoit Orihuela's avatar Benoit Orihuela Committed by Andrea Il Grande
Browse files

feat(wip): bootstrap mock support for dist ops

parent c7167bc1
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.re
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource

Test Setup          Setup Entity Id And Registration
Test Teardown       Delete Created Entities And Registration
@@ -18,13 +19,28 @@ ${entity_payload_filename} vehicle-simple-attributes.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld


*** Test Cases ***
D001_01_inc Create Entity On Both Context Broker and Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_1
    [Documentation]    Check that if one requests the Context Broker to create an entity that matches an inclusive registration, this is created on the Context Source too
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_1

    Set Stub Reply    POST    /ngsi-ld/v1/entities    201
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    # Works after adding these two lines in venv/lib/python3.12/site-packages/HttpCtrl/http_handler.py
    #    at line 86-87:
    #    request = Request(host, port, method, self.path, self.headers, body)
    #    RequestStorage().push(request)
    Wait for redirected request

    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Log    ${payload}
    ${request_headers}=    Get Request Headers
    Log    ${request_headers}

    @{entities_id}=    Create List    ${entity_id}
    ${response_query}=    Query Entities    entity_types=Vehicle    local=true    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_query.status_code}
@@ -46,11 +62,9 @@ Setup Entity Id And Registration
    ...    entity_id=${entity_id}
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response1.status_code}
    Start Context Source Mock Server

Delete Created Entities And Registration
    Delete Context Source Registration    ${registration_id}
    Delete Entity By Id    ${entity_id}
    Delete Entity By Id    ${entity_id}    base_url=${remote_url}
    

    
 No newline at end of file
    Stop Context Source Mock Server
+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ ${ERROR_TYPE_BAD_REQUEST_DATA} https://uri.etsi.org/ngsi-ld/err
${ERROR_TYPE_RESOURCE_NOT_FOUND}                https://uri.etsi.org/ngsi-ld/errors/ResourceNotFound

${response}                                     ${EMPTY}
${context_source_url}                           http://${context_source_host}:${context_source_port}


*** Keywords ***
@@ -31,7 +32,7 @@ Prepare Context Source Registration From File
    ${registration_payload}=    Update Value To JSON
    ...    ${registration_payload}
    ...    $..endpoint
    ...    ${context_source_endpoint}
    ...    ${context_source_url}
    IF    '${entity_id}' != ''
        ${dict}=    Create Dictionary    id=${entity_id}
        ${registration_payload}=    Add Object To JSON
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ Wait for redirected request
    Wait For Request    ${timeout}
    Reply By    200

Answer to Create Entity
    Set Stub Reply    POST    /ngsi-ld/v1/entities    201

Stop Context Source Mock Server
    # Terminate HTTP Server
    Stop Server