from django.db import models # Create your models here. from apps.plan.models import TestPlan from apps.software.models import Software from apps.user.models import User class TestTask(models.Model): id = models.CharField(max_length=128, unique=True, primary_key=True, verbose_name='测试任务编号', default='TestLaboratory_V1_Task_1') title = models.CharField(max_length=50, verbose_name='测试任务标题') executor = models.ForeignKey(User, null=True, on_delete=models.CASCADE, verbose_name='测试任务执行者') # 0: 发布,release;(此阶段可以上传未执行的测试用例)1:执行测试用例,execute(此阶段需上传包含测试结果的测试用例);2:执行完成 state = models.IntegerField(verbose_name='测试任务状态') description = models.TextField(verbose_name='测试任务描述') plan = models.ForeignKey(TestPlan, on_delete=models.CASCADE, verbose_name='测试任务所属计划') statement_file = models.TextField(verbose_name='说明文档id文件') case_file = models.TextField(null=True, verbose_name='测试用例文档') case_all = models.IntegerField(null=True, verbose_name='全部测试用例数量') case_not_execute = models.IntegerField(null=True, verbose_name='未执行测试用例数量') case_success = models.IntegerField(null=True, verbose_name='成功测试用例数量') case_fail = models.IntegerField(null=True, verbose_name='失败测试用例数量') create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') delete = models.BooleanField(default=False) def __str__(self): return self.title class Meta: verbose_name = '测试任务' verbose_name_plural = verbose_name db_table = 'task' class TestCase(models.Model): id = models.CharField(max_length=30, unique=True, primary_key=True, verbose_name='测试用例编号', default='TestLaboratory_V1_Case_1') task = models.ForeignKey(TestTask, on_delete=models.CASCADE, verbose_name='测试用例所在测试任务', default='TestLaboratory_V1_Task_1') id_in_task = models.CharField(max_length=30, verbose_name='在测试任务中编号', default='1') software = models.ForeignKey(Software, null=True, on_delete=models.CASCADE, verbose_name='测试软件') executor_id = models.ForeignKey(User, null=True, on_delete=models.CASCADE, verbose_name='执行者id') version = models.CharField(max_length=30, null=True, verbose_name='软件版本') name = models.CharField(max_length=50, verbose_name='名称') state = models.IntegerField(verbose_name='状态') writer = models.CharField(max_length=30, verbose_name='测试用例编写人', null=True) executor = models.CharField(max_length=30, verbose_name='测试用例执行人', null=True) assessor = models.CharField(max_length=30, verbose_name='测试用例评审员', null=True) requisite = models.TextField(null=True, verbose_name='前置条件') priority = models.CharField(max_length=10, null=True, verbose_name='优先级') environment = models.TextField(null=True, verbose_name='测试环境') type = models.CharField(max_length=30, null=True, verbose_name='测试类型') process = models.TextField(verbose_name='测试步骤') expected_result = models.TextField(verbose_name='预期结果') actual_result = models.TextField(verbose_name='实际结果', null=True) create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间') delete = models.BooleanField(default=False) remark = models.TextField(null=True, verbose_name='备注') def __str__(self): return self.name class Meta: verbose_name = '测试用例' verbose_name_plural = verbose_name db_table = 'test_case'