-- Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
-- 
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN \"AS IS\" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.

local skynet = require 'skynet'
local log = require 'mc.logging'
local mdb = require 'mc.mdb'
require 'skynet.manager'
require 'thermal_mgmt.json_types.CoolingPolicy'

local test_cooling_policy = {}

-- 获取必要的代理对象
local function l_objs_init(bus)
    local ok
    local c_policy_100_obj, c_policy_101_obj, c_policy_102_obj, c_policy_103_obj
    local c_policy_104_obj, c_policy_105_obj, c_policy_106_obj, c_policy_108_obj
    local c_policy_100_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_100_0101'
    local c_policy_101_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_101_0101'
    local c_policy_102_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_102_0101'
    local c_policy_103_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_103_0101'
    local c_policy_104_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_104_0101'
    local c_policy_105_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_105_0101'
    local c_policy_106_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_106_0101'
    local c_policy_108_path = '/bmc/kepler/Systems/1/CoolingPolicy/CoolingPolicy_1_108_0101'

    ok, c_policy_100_obj = pcall(mdb.get_object, bus, c_policy_100_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_101_obj = pcall(mdb.get_object, bus, c_policy_101_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_102_obj = pcall(mdb.get_object, bus, c_policy_102_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_103_obj = pcall(mdb.get_object, bus, c_policy_103_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_104_obj = pcall(mdb.get_object, bus, c_policy_104_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_105_obj = pcall(mdb.get_object, bus, c_policy_105_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_106_obj = pcall(mdb.get_object, bus, c_policy_106_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)
    ok, c_policy_108_obj = pcall(mdb.get_object, bus, c_policy_108_path, 'bmc.kepler.Systems.CoolingPolicy')
    assert(ok)

    return {
        ['c_policy_100_obj'] = c_policy_100_obj,
        ['c_policy_101_obj'] = c_policy_101_obj,
        ['c_policy_102_obj'] = c_policy_102_obj,
        ['c_policy_103_obj'] = c_policy_103_obj,
        ['c_policy_104_obj'] = c_policy_104_obj,
        ['c_policy_105_obj'] = c_policy_105_obj,
        ['c_policy_106_obj'] = c_policy_106_obj,
        ['c_policy_108_obj'] = c_policy_108_obj
    }
end

function test_cooling_policy.main(bus)
    log:info('================ test policy obj valid start ================')
    local l_objs = l_objs_init(bus)
    assert(l_objs['c_policy_100_obj'].IsValid == 0)
    assert(l_objs['c_policy_101_obj'].IsValid == 1)
    assert(l_objs['c_policy_102_obj'].IsValid == 1)
    assert(l_objs['c_policy_103_obj'].IsValid == 0)
    assert(l_objs['c_policy_104_obj'].IsValid == 1)
    assert(l_objs['c_policy_105_obj'].IsValid == 0)
    assert(l_objs['c_policy_106_obj'].IsValid == 1)
    assert(l_objs['c_policy_108_obj'].IsValid == 0)
    log:info('================ test policy obj valid end ================')
end

return test_cooling_policy