测试开发进阶(三十七)
报告模块
报告下载-中文文件
下载时候如果报告名中有中文,则可能出现乱码
1 | from django.utils.encoding import escape_uri_path |
使用escape_uri_path可以解决
报告展示
1 | def retrieve(self, request, *args, **kwargs): |

配置模块

配置管理页面展示需要展示
配置名称所属项目所属接口

其中:配置信息里面的外键是所属接口

接口里面的外键是所属项目
所以要在序列化器中处理掉这里面的关系
序列化器
InterfacesAnotherSerializer拿到
- 项目名称
- 项目ID
- 接口ID
ConfiguresSerializer里面用InterfacesAnotherSerializer拿到的东西进行展示
注意:create中validated_data拿到的是一个对象,需要
1 | interface_dict = validated_data.pop('interface') |
将它变成对应的ID

1 | { |
1 | from rest_framework import serializers |
在utils.validates.whether_existed_project_id中检查项目id是否存在
1 | def whether_existed_project_id(value): |
视图
查看lemon-test/src/components/page/ConfigureAdd.vue
1 | data: function () { |
需要后台返回一个字典:
1 | datas = { |
1 | import json |

用例模块
序列化器
list接口对应的序列化器:TestcasesSerializer

1 | from rest_framework import serializers |
用例编辑



1 | import json |