*** Settings ***
Documentation     Test suite for checking default images
Suite Setup       Read InputFile
Test Template     Verify Image Check
Library           Collections
Library           String
Library           OperatingSystem
Library           XML
Library           RequestsLibrary
Library           ../Framework/utils/utils.py
Library           ../Framework/restApi.py

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

*** Test Cases ***    TYPE
Test Default Images
                      IMAGE

*** Keywords ***
Read InputFile
    ${defaultImageList}=    utils.jsonToList    ${PATHFILE}    imagesInfo
    ${status}    ${dynamicImageList}=    Run Keyword And Ignore Error    utils.get_dynamic_resources    ${PROFILE_FILE}    xos_images
    ${imageList}=    Set Variable If    '${status}' == 'FAIL'    ${defaultImageList}    ${dynamicImageList}
    Set Suite Variable    ${imageList}

Verify Image Check
    [Arguments]    ${type}
    Run Keyword If    "${type}" == "IMAGE"    Test Image Check

Test Image Check
    ${json_result}=    restApi.ApiGet    CH_CORE_IMAGES
    ${json_result_list}=    Get From Dictionary    ${json_result}    items
    Log    ${json_result_list}
    ${image_list}=    Get Variable Value    ${imageList}
    ${test_result}=    utils.compare_list_of_dicts    ${image_list}    ${json_result_list}
    Should Be True    ${test_result}

