完善测试环境设计+完成用例模块
测试环境models
class PlatForm(models.Model):
"""
各种测试端(app, web, H5等)
none 代表可以为None, blank: 代表可以什么都不写(后台编辑)
"""
name = models.CharField(max_length=20, null=True, blank=True)
interval = models.CharField(max_length=200, null=True, blank=True) # 监控时间间隔
phone = models.CharField(max_length=200, null=True, blank=True) # 电话号码
email = models.CharField(max_length=200, null=True, blank=True) # 邮箱
ding_talk = models.CharField(max_length=200, null=True, blank=True) # 钉钉
host = models.CharField(max_length=500, null=True, blank=True) # 监控host
def __str__(self):
return f'PlatForm<{self.name}>'
调试包
调试包: 用例cases + public 模块 + 测试报告
用例cases
- unittest为基础 test_01.py test_02.py
- 支持线性脚本
- 数据关键字驱动脚本
- pageobject模式
调试包从demo_client复制自动生成 命名为client_${{plat_id}}
复制调试包
# 复制出自己的调试包
new_plat_name = f'client_{plat.id}'
demo_client_path = os.path.join('client', 'demo_client')
new_path = os.path.join('client', new_plat_name)
shutil.copytree(demo_client_path, new_path)
django获取新创建的对象
plat = PlatForm.objects.create(name=name, host=host, interval=interval)
url中带变量
re_path('case_list/(?P<pid>.*)/', case_list)