-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under 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 lu = require 'luaunit'
local c_pcie_device = require 'device.class.pcie_device'
local c_ocp_device = require 'device.class.ocp_card'
local cmn = require 'common'
local ipmi = require 'ipmi'

local PCIECARD_INTERFACE <const> = 'bmc.kepler.Systems.PCIeDevices.PCIeCard'

TestOCPCard = {}

function TestOCPCard:test_update_board_id()
    local pcie_addr_obj = {
        ['get_prop'] = function()
            return 'test'
        end
    }
    local ocp_obj = {
        ['set_prop'] = function()
            return 'set'
        end
    }
    local ret = c_ocp_device.update_vid_did(ocp_obj, pcie_addr_obj)
    lu.assertEquals(ret, nil)
    local ret = c_ocp_device.update_description(ocp_obj, "card")
    lu.assertEquals(ret, nil)
end

function TestOCPCard:test_check_count()
    c_ocp_device.check_count = 0
    c_ocp_device:add_check_count()
    local ret = c_ocp_device:need_check()
    lu.assertEquals(ret, true)

    c_ocp_device:add_check_count()
    c_ocp_device:add_check_count()
    ret = c_ocp_device:need_check()
    lu.assertEquals(ret, false)
end