Commit 59eca008 authored by Ken Zangelin's avatar Ken Zangelin
Browse files

fix(D010_01_aux): JSON-serialise stub body (HttpCtrl does not auto-encode dicts)

parent aed085be
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -28,7 +28,13 @@ D010_01_aux Retrieve Entity That Exists On Both The Context Source And The Conte
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-auxiliary    4_3_6_2    5_7_1
    ${entity_body}=    Load Entity    ${entity_payload_filename}    ${entity_id}
    ${entity_fragment}=    Load JSON From File    ${EXECDIR}/data/entities/fragmentEntities/${fragment_filename}
    Set Stub Reply    GET    /ngsi-ld/v1/entities/${entity_id}    200    ${entity_body}
    # `Load Entity` returns a Python dict; HttpCtrl's `Set Stub Reply` writes
    # the body argument verbatim and does NOT auto-serialise non-string values
    # (a dict passed straight in: `len(dict)` reports the key count for the
    # Content-Length header, and `wfile.write(dict)` raises silently — the
    # mock ends up sending headers only). Serialise to a JSON string first.
    ${entity_body_json}=    Evaluate    json.dumps($entity_body)    json
    Set Stub Reply    GET    /ngsi-ld/v1/entities/${entity_id}    200    ${entity_body_json}
    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}

    Check Response Status Code    200    ${response.status_code}