from xdevice import platform_logger
from core.utils import scan_support_product
from core.config.config_manager import FrameworkConfigManager
LOG = platform_logger("Console")
class Parameter(object):
@classmethod
def get_valid_test_level_string(cls, test_level):
if test_level == "":
return ""
level_key_list = ["0", "1", "2", "3", "4"]
level_list = test_level.strip(",").split(",")
check_flag = True
for item in level_list:
item = item.strip(" ")
if not item.isdigit():
check_flag = False
LOG.warning("The testlevel you entered is incorrect.")
break
if item not in level_key_list:
LOG.warning("The testlevel you entered is incorrect.")
check_flag = False
break
test_level_string = ""
if check_flag:
for item in level_list:
item = item.strip(" ")
test_level_string = f"{test_level_string}{item},"
test_level_string = test_level_string.strip(",")
return test_level_string
@classmethod
def get_testtype_list(cls, type_list):
test_type_list = []
if "ALL" not in type_list:
test_category_dic = \
FrameworkConfigManager().get_test_category_info()
for item in type_list:
item = item.upper()
data = test_category_dic.get(item, None)
if data is None:
LOG.warning("data is None.")
test_type_list = []
break
test_type_list.append(data[0])
else:
test_type_list = FrameworkConfigManager().get_all_category_info()
return test_type_list
def check_run_parameter(self, options):
if options.productform is None or options.productform == "":
LOG.warning("The productform is incorrect.")
return False
if "" != options.testcase and "" != options.testlevel:
LOG.warning("The -l and -c parameters cannot exist at the \
same time.")
return False
level_string = self.get_valid_test_level_string(options.testlevel)
if options.testlevel != "" and level_string == "":
LOG.warning("The testlevel you entered is incorrect.")
return False
return True