|
@@ -9,8 +9,9 @@ from TestLaboratory.settings import SOFTWARE_ROOT, CASE_FILE_EXPORT
|
|
from apps.file.models import FileManager
|
|
from apps.file.models import FileManager
|
|
from apps.log.models import get_log, gen_log
|
|
from apps.log.models import get_log, gen_log
|
|
from apps.software.models import Software, Version
|
|
from apps.software.models import Software, Version
|
|
-from apps.task.models import TestCase
|
|
|
|
|
|
+from apps.task.models import TestCase, BeidouCase
|
|
from apps.user.middleware.rolecontrol import RoleControl
|
|
from apps.user.middleware.rolecontrol import RoleControl
|
|
|
|
+from apps.user.models import User
|
|
from util_xlsx import write_to_xlsx
|
|
from util_xlsx import write_to_xlsx
|
|
from utils.util_add_id import gen_next_id
|
|
from utils.util_add_id import gen_next_id
|
|
|
|
|
|
@@ -25,6 +26,15 @@ logger = logging.getLogger('django')
|
|
class VersionView(APIView):
|
|
class VersionView(APIView):
|
|
authentication_classes = []
|
|
authentication_classes = []
|
|
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def convert_to_string(word_list):
|
|
|
|
+ for i in range(len(word_list)):
|
|
|
|
+ if word_list[i] is None:
|
|
|
|
+ word_list[i] = ''
|
|
|
|
+ elif not isinstance(word_list[i], str):
|
|
|
|
+ word_list[i] = str(word_list[i])
|
|
|
|
+ return word_list
|
|
|
|
+
|
|
# create version
|
|
# create version
|
|
@staticmethod
|
|
@staticmethod
|
|
@RoleControl
|
|
@RoleControl
|
|
@@ -190,13 +200,13 @@ class VersionView(APIView):
|
|
cases = None
|
|
cases = None
|
|
file_name = None
|
|
file_name = None
|
|
if export_type == '0':
|
|
if export_type == '0':
|
|
- cases = TestCase.objects.filter(software=software, version=version_number, delete=False)
|
|
|
|
|
|
+ cases = BeidouCase.objects.filter(software=software, version=version_number, delete=False)
|
|
file_name = '全部测试用例.xls'
|
|
file_name = '全部测试用例.xls'
|
|
elif export_type == '1':
|
|
elif export_type == '1':
|
|
- cases = TestCase.objects.filter(~Q(state=0), software=software, version=version_number, delete=False)
|
|
|
|
|
|
+ cases = BeidouCase.objects.filter(~Q(state=0), software=software, version=version_number, delete=False)
|
|
file_name = '已执行测试用例.xls'
|
|
file_name = '已执行测试用例.xls'
|
|
else:
|
|
else:
|
|
- cases = TestCase.objects.filter(software=software, version=version_number, state=2, delete=False)
|
|
|
|
|
|
+ cases = BeidouCase.objects.filter(software=software, version=version_number, state=2, delete=False)
|
|
file_name = '不合格测试用例.xls'
|
|
file_name = '不合格测试用例.xls'
|
|
|
|
|
|
if not cases:
|
|
if not cases:
|
|
@@ -209,27 +219,37 @@ class VersionView(APIView):
|
|
os.makedirs(file_dir)
|
|
os.makedirs(file_dir)
|
|
file_path = file_dir + "/" + file_name
|
|
file_path = file_dir + "/" + file_name
|
|
|
|
|
|
- cases_info = [['被测软件ID:', software_id],
|
|
|
|
- ['被测软件名:', software.name],
|
|
|
|
- ['被测软件版本', version_number],
|
|
|
|
- ['编号', '名称', '前置条件', '优先级', '测试环境', '测试类型', '测试步骤', '预期结果', '实际结果', '状态',
|
|
|
|
- '编写人', '评审员', '执行人', '备注']]
|
|
|
|
|
|
+ cases_info = [
|
|
|
|
+ ['测试项目', '版本', '测试内容', '定位精度', '定时精度', '伪距测量精度', '载波测量精度', '测速精度',
|
|
|
|
+ '捕获灵敏度', '接收灵敏度', '跟踪灵敏度', '功率范围', '自主完好性', '系统完好性', '首次捕获时间',
|
|
|
|
+ '失锁重捕时间', '定位测速更新率', '跟踪通道数', '最大速度', '最大加速度', '执行结果', '测试人员', '备注']]
|
|
|
|
|
|
for case in cases:
|
|
for case in cases:
|
|
- state = '未执行'
|
|
|
|
- if case.state == 1:
|
|
|
|
- state = '执行成功'
|
|
|
|
- elif case.state == 2:
|
|
|
|
- state = '执行失败'
|
|
|
|
- cases_info.append([case.id_in_task, case.name, case.requisite, case.priority, case.environment,
|
|
|
|
- case.type, case.process, case.expected_result, case.actual_result, state,
|
|
|
|
- case.writer, case.assessor, case.executor, case.remark])
|
|
|
|
|
|
+ power = ''
|
|
|
|
+ if case.power_range_low and case.power_range_high:
|
|
|
|
+ power = str(case.power_range_low) + '-' + str(case.power_range_high)
|
|
|
|
+ state = '成功'
|
|
|
|
+ if case.state == 2:
|
|
|
|
+ state = '失败'
|
|
|
|
+ executor_name = User.objects.filter(id=case.executor_id)[0].username
|
|
|
|
+
|
|
|
|
+ cases_info.append(VersionView.convert_to_string(
|
|
|
|
+ [software.name, case.version, case.title, case.positioning_accuracy, case.timing_accuracy,
|
|
|
|
+ case.pseudo_range_measurement_accuracy, case.carrier_measurement_accuracy,
|
|
|
|
+ case.speed_measurement_accuracy, case.sensitivity_capture, case.receiving_sensitivity,
|
|
|
|
+ case.sensitivity_track, power, case.self_integrity, case.system_integrity, case.capture_time,
|
|
|
|
+ case.recapture_time, case.update_rate, case.trace_channels, case.max_velocity, case.max_acceleration,
|
|
|
|
+ state, executor_name, case.remark]
|
|
|
|
+ ))
|
|
|
|
|
|
sio = write_to_xlsx(file_path, cases_info)
|
|
sio = write_to_xlsx(file_path, cases_info)
|
|
sio.seek(0)
|
|
sio.seek(0)
|
|
- response = HttpResponse(sio.getvalue(), content_type='multipart/form-data')
|
|
|
|
- response['Content-Disposition'] = 'attachment; filename="{0}"'.format(file_name).encode('utf-8')
|
|
|
|
- response.write(sio.getvalue())
|
|
|
|
|
|
+ response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel')
|
|
|
|
+ response['Content-Disposition'] = 'attachment; filename="{0}"'.format(file_name).encode('utf-8',
|
|
|
|
+ 'ISO-8859-1')
|
|
|
|
+ # response = HttpResponse(sio.getvalue(), content_type='multipart/form-data')
|
|
|
|
+ # response['Content-Disposition'] = 'attachment; filename="{0}"'.format(file_name).encode('utf-8')
|
|
|
|
+ # response.write(sio.getvalue())
|
|
# executor, action, method = get_log(request)
|
|
# executor, action, method = get_log(request)
|
|
# gen_log(action, "目标版本", software.name + "-" + version.number, method, executor)
|
|
# gen_log(action, "目标版本", software.name + "-" + version.number, method, executor)
|
|
return response
|
|
return response
|