from UniTAP.dev.modules.dut_tests.test_group_params_types import Param


class Hdcp1ATestParam:
    """
    Class `Hdcp1ATestParam` describes requirement parameters for HDCP 1A tests:
    - Set and get `timeout`. Describes test timeout, in milliseconds.
    - Set and get `revoke_id`. Describes Revoke ID.
    - Set and get `dut_caps_flag`. Describes source DUT capabilities flags.
    """
    def __init__(self, json_obj):
        self.__timeout = Param(json_obj["TSI_TEST_CFG_HDCP2_1A_TIMEOUT"])
        self.__revoke_id = Param(json_obj["TSI_TEST_CFG_HDCP2_1A_REVOKEID"])
        self.__dut_caps_flag = Param(json_obj["TSI_TEST_CFG_HDCP2_1A_SRC_DUT_CAP"])

    @property
    def timeout(self) -> int:
        """
        Set and get test timeout, in milliseconds.

        Returns:
            object of int type
        """
        return self.__timeout.default_value

    @timeout.setter
    def timeout(self, timeout: int):
        if not(self.__timeout.min_value < timeout < self.__timeout.max_value):
            raise ValueError(f"Timeout cannot be less than {self.__timeout.min_value} and more than "
                             f"{self.__timeout.max_value}.")
        self.__timeout.default_value = timeout

    @property
    def revoke_id(self) -> int:
        """
        Set and get Revoke ID.

        Returns:
            object of int type
        """
        return self.__revoke_id.default_value

    @revoke_id.setter
    def revoke_id(self, revoke_id: list):
        if len(revoke_id) == 0:
            raise ValueError(f"Revoke ID list length must more than 0")
        self.__revoke_id.default_value = revoke_id

    @property
    def dut_caps_flag(self) -> bool:
        """
        Set and get DUT caps flag support.

        Returns:
            object of bool type
        """
        return self.__dut_caps_flag.default_value

    @dut_caps_flag.setter
    def dut_caps_flag(self, dut_caps_flag: bool):
        self.__dut_caps_flag.default_value = dut_caps_flag
