Commit 0da19e39 authored by lopezaguilar's avatar lopezaguilar
Browse files

Resolve issues in 038_01, 038_02, and 038_05

parent a0f70bae
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -26,9 +26,22 @@ ${subscription_payload_file_path}= csourceSubscriptions/subscription-sample
    ...    subscription_id=${subscription_id}
    ...    context=${ngsild_test_suite_context}
    ...    accept=${CONTENT_TYPE_LD_JSON}
    ${ignored_attributes}=    Create List    ${status_regex_expr}

    # We need to ignore the Additional Members ('lastFailure', 'lastNotification', 'timesFailed', 'timesSent')
    ${ignored_attributes}=    Create List
    ...    ${status_regex_expr}
    ...    ${lastfailure_regex_expr}
    ...    ${lastNotification_regex_expr}
    ...    ${timesFailed_regex_expr}
    ...    ${timesSent_regex_expr}

    Check Created Resource Set To    ${subscription_payload}    ${response1.json()}    ${ignored_attributes}

    Check Dictionary Might Contain Additional Members    ${response1.json()}    lastNotification
    Check Dictionary Might Contain Additional Members    ${response1.json()}    lastFailure
    Check Dictionary Might Contain Additional Members    ${response1.json()}    lastSuccess
    Check Dictionary Might Contain Additional Members    ${response1.json()}    timesSent


*** Keywords ***
Generate Random Ids For Context Source Registration Subscriptions
+13 −5
Original line number Diff line number Diff line
@@ -4,13 +4,13 @@ Documentation Check that you can create a context source registration subs
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistrationSubscription.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/HttpUtils.resource

Suite Teardown      Delete Created Context Source Registration Subscriptions


*** Variables ***
${subscription_payload_file_path}=      csourceSubscriptions/subscription-sample.jsonld
${subscription_id}=                     ${EMPTY}


*** Test Cases ***
@@ -18,11 +18,15 @@ ${subscription_payload_file_path}= csourceSubscriptions/subscription-sample
    [Documentation]    Check that you can create a context source registration subscription without providing an id and it will be automatically generated
    [Tags]    csrsub-create    5_11_2
    ${subscription_payload}=    Load Test Sample    ${subscription_payload_file_path}
    Remove From Dictionary    ${subscription_payload}    id
    ${response}=    Create Context Source Registration Subscription    ${subscription_payload}
    ${subscription_id}=    Fetch Id From Response Location Header    ${response.headers}
    Check Response Status Code    201    ${response.status_code}
    Check Response Headers Containing URI set to    ${subscription_id}    ${response.headers}

    Dictionary Should Contain Key    ${response.headers}    Location    msg=HTTP Headers do not contain key 'Location'
    ${subscription_id}=    Get From Dictionary    ${response.headers}    Location
    Set Suite Variable    ${subscription_id}

    Check Response Status Code    201    ${response.status_code}

    ${response1}=    Retrieve Context Source Registration Subscription
    ...    subscription_id=${subscription_id}
    ...    context=${ngsild_test_suite_context}
@@ -33,4 +37,8 @@ ${subscription_payload_file_path}= csourceSubscriptions/subscription-sample

*** Keywords ***
Delete Created Context Source Registration Subscriptions
    IF    "${subscription_id}" != "${EMPTY}"
        Delete Context Source Registration Subscription    ${subscription_id}
    ELSE
        Log To Console    \nThere was no Context Source Registration Subscription to delete\n
    END
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ ${subscription_payload_file_path}= csourceSubscriptions/subscription-expire
    [Tags]    csrsub-create    5_11_2
    ${subscription_payload_sample}=    Load Test Sample    ${subscription_payload_file_path}    ${subscription_id}
    ${current_date}=    Get Current Date    time_zone=UTC    result_format=${date_format}
    ${expiresAt}=    Add Time To Date    ${current_date}    10 seconds    date_format=${date_format}
    ${expiresAt}=    Add Time To Date    ${current_date}    10 seconds    result_format=${date_format}
    ${subscription_payload}=    Update Value To JSON    ${subscription_payload_sample}    $..expiresAt    ${expiresAt}
    ${response}=    Create Context Source Registration Subscription    ${subscription_payload}
    Check Response Status Code    201    ${response.status_code}
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ class GenerateRobotData:

        self.config_variables = ParseVariablesFile()
        self.robot = ParseRobotFile(filename=robot_file, execdir=execdir, config_file=self.config_variables)
        # TODO: the robot file can provide several ApiUtils not only one
        self.apiutils = [ParseApiUtilsFile(filename=file) for file in self.robot.resource_files]
        self.robot.set_apiutils(self.apiutils)

+34 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@ ${notification_timestamps_regex_expr}= root\\['last.*'\\]
${notification_endpoint_uri_regex_expr}=    root\\['endpoint'\\]\\['uri'\\]
${context_regex_expr}=                      root\\['@context'\\]
${status_regex_expr}=                       root\\['status'\\]
${lastfailure_regex_expr}=                  root\\['lastFailure'\\]
${lastNotification_regex_expr}=             root\\['lastNotification'\\]
${timesFailed_regex_expr}=                  root\\['timesFailed'\\]
${timesSent_regex_expr}=                    root\\['timesSent'\\]


*** Keywords ***
@@ -444,3 +448,33 @@ Check Retrieving Context Source Registration
    ...    accept=${accept}
    ${ignored_attributes}=    Create List    ${status_regex_expr}    @context
    Check Updated Resource Set To    ${registration_payload}    ${response.json()}    ${ignored_attributes}

Check Dictionary Might Contain Additional Members
    # Check the Additional Members 5.2.14.2 in the NotificationParams data structure
    [Arguments]    ${dictionary}    ${key}
    Log    Dictionary Might Contain Key with a specific type
    Log    Dictionary: ${dictionary}
    Log    Key: ${key}

    ${value}=    Evaluate    $dictionary.get($key)

    IF    '${value}' != '' and '${value}' != 'None'
        IF    "${key}" == "lastNotification" or "${key}" == "lastFailure" or "${key}" == "lastSuccess"
            # Need to check that there is a DateTime value
            ${date}=    Parse Ngsild Date    ${dictionary}[${key}]
            Should Not Be Equal
            ...    ${date}
            ...    ${None}
            ...    The Additional Member ${key} contains a value (${value}) that it is not in DateTime format
        END
        IF    "${key}" == "timesSent"
            # Need to check that there is a Integer value
            ${type int}=    Evaluate    type(${dictionary}[${key}]).__name__
            Should Be Equal
            ...    ${type int}
            ...    int
            ...    The Additonal Member ${key} contains a value (${value}) that it is not in Number format
        END
    ELSE
        Log    The key '${key}' is not present in the dictionary
    END
Loading