Files
cdtestplant_v1/utils/chapter_tools/csx_chapter.py
2025-04-29 18:09:00 +08:00

19 lines
833 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from apps.project.models import Round
from utils.util import get_dict_info
def create_csx_chapter_dict(one_round: Round):
"""传入轮次对象返回测试项类型字典key的数组/测试项key的dict以便后续使用"""
testType_list = []
last_chapter_items = {}
if one_round:
for csx in one_round.rtField.all():
if csx.testType not in testType_list:
testType_list.append(csx.testType)
# 排序需要查字典里面index来排序
testType_list.sort(key=lambda x: get_dict_info('testType', x)['index'], reverse=False)
for test_type in testType_list:
last_chapter_items[test_type] = []
for csx in one_round.rtField.all():
last_chapter_items[csx.testType].append(csx.key)
return testType_list, last_chapter_items