*** Settings ***
Documentation     Test suite for checking default services
Suite Setup       Read InputFile
Test Template     Verify Service Sanity
Library           Collections
Library           String
Library           OperatingSystem
Library           XML
Library           RequestsLibrary
Library           ../Framework/utils/utils.py
Library           ../Framework/restApi.py
Resource          ../Framework/utils/utils.robot

*** Variables ***
${PROFILE}        mock-rcord
${PROFILE_FILE}   ${CURDIR}/../../../../../../orchestration/profiles/${PROFILE}/${PROFILE}.yml

*** Test Cases ***    TYPE
Test Service Sanity
                      SANITY

*** Keywords ***
Read InputFile
    ${status}    ${dynamicServiceList}=    Run Keyword And Ignore Error    utils.get_dynamic_resources    ${PROFILE_FILE}    xos_services
    Run Keyword If    '${status}' == 'FAIL'    Fail    No Services in given profile manifest
    Set Suite Variable    ${dynamicServiceList}
    ##need to remove openstack and onos from xos_services list in each manifest as these services arent treated as typical xos synchronizers
    utils.Remove Value From List    ${dynamicServiceList}    openstack
    utils.Remove Value From List    ${dynamicServiceList}    onos
    utils.Remove Value From List    ${dynamicServiceList}    exampleservice
    Log    ${dynamicServiceList}

Verify Service Sanity
    [Arguments]    ${type}
    Run Keyword If    "${type}" == "SANITY"    Test Service Sanity

Test Service Sanity
    ${json_result}=    restApi.ApiGet    CH_CORE_SERVICES
    ${json_result_list}=    Get From Dictionary    ${json_result}    items
    Log    ${json_result_list}
    ${dList}=    Get Variable Value    ${dynamicServiceList}
    ${test_result}=    utils.compare_list_of_dicts    ${dList}    ${json_result_list}
    Should Be True    ${test_result}
