*** 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           CORDRobot
Library           ImportResource  resources=CORDRobot

*** 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    CORDRobot.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
    CORDRobot.Remove Value From List    ${dynamicServiceList}    openstack
    CORDRobot.Remove Value From List    ${dynamicServiceList}    onos
    CORDRobot.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}=    CORDRobot.ApiGet    CH_CORE_SERVICES
    ${json_result_list}=    Get From Dictionary    ${json_result}    items
    Log    ${json_result_list}
    ${dList}=    Get Variable Value    ${dynamicServiceList}
    ${test_result}=    CORDRobot.compare_list_of_dicts    ${dList}    ${json_result_list}
    Should Be True    ${test_result}
