Commit 979c66ce authored by kzangeli's avatar kzangeli
Browse files

integration: D009_01 stub-reply + multi-instance assertion fixes (doubt #100)

parent 806bcaa8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -41,7 +41,10 @@ D009_01_exc Replace Entity Attribute
    ${stub_count}=    Get Stub Count    PUT    /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed
    Should Be Equal As Integers    ${stub_count}    1

    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_id}
    # The Context Source serves the entity carrying the replaced attribute —
    # the stub reply must be an entity document, not the bare entity id.
    ${entity_reply}=    Create Dictionary    id=${entity_id}    type=Vehicle    speed=${attribute_payload}[speed]
    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_reply}
    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${new_attribute}=    Get From Dictionary    ${response.json()}    speed
    Should Be Equal    ${attribute_payload}[speed][value]    ${new_attribute}[value]
+11 −2
Original line number Diff line number Diff line
@@ -38,10 +38,19 @@ D009_01_inc Replace Entity Attribute
    ...    context=${ngsild_test_suite_context}
    Check Response Status Code    204    ${response.status_code}

    Set Stub Reply    GET    /ngsi-ld/v1/entities/${entity_id}    200    ${entity_id}
    # The Context Source serves the entity carrying the replaced attribute —
    # the stub reply must be an entity document, not the bare entity id.
    ${entity_reply}=    Create Dictionary    id=${entity_id}    type=Vehicle    speed=${attribute_payload}[speed]
    Set Stub Reply    GET    /ngsi-ld/v1/entities/${entity_id}    200    ${entity_reply}
    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${new_attribute}=    Get From Dictionary    ${response.json()}    speed
    Should Be Equal    ${attribute_payload}[speed][value]    ${new_attribute}[value]
    # The entity keeps its datasetId'd speed instance (inclusive — nothing is
    # detached), so the replaced default instance arrives alongside it and
    # speed may be a multi-instance array — assert against the default
    # (datasetId-less) instance.
    ${default_instance}=    Evaluate
    ...    [i for i in ($new_attribute if isinstance($new_attribute, list) else [$new_attribute]) if 'datasetId' not in i][0]
    Should Be Equal    ${attribute_payload}[speed][value]    ${default_instance}[value]


*** Keywords ***
+5 −2
Original line number Diff line number Diff line
@@ -47,12 +47,15 @@ D009_01_red Replace Entity Attribute
    ${stub_count}=    Get Stub Count    PUT    /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed
    Should Be Equal As Integers    ${stub_count}    1

    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_id}
    # The Context Sources serve the entity carrying the replaced attribute —
    # the stub replies must be entity documents, not the bare entity id.
    ${entity_reply}=    Create Dictionary    id=${entity_id}    type=Vehicle    speed=${attribute_payload}[speed]
    Set Stub Reply    GET    /broker1/ngsi-ld/v1/entities/${entity_id}    200    ${entity_reply}
    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${new_attribute}=    Get From Dictionary    ${response.json()}    speed
    Should Be Equal    ${attribute_payload}[speed][value]    ${new_attribute}[value]

    Set Stub Reply    GET    /broker2/ngsi-ld/v1/entities/${entity_id}    200    ${entity_id}
    Set Stub Reply    GET    /broker2/ngsi-ld/v1/entities/${entity_id}    200    ${entity_reply}
    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}
    ${new_attribute}=    Get From Dictionary    ${response.json()}    speed
    Should Be Equal    ${attribute_payload}[speed][value]    ${new_attribute}[value]
+24 −755

File changed.

Preview size limit exceeded, changes collapsed.