models.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. from django.db import models
  2. # Create your models here.
  3. from apps.plan.models import TestPlan
  4. from apps.software.models import Software
  5. from apps.user.models import User
  6. class TestTask(models.Model):
  7. id = models.CharField(max_length=128, unique=True, primary_key=True, verbose_name='测试任务编号',
  8. default='TestLaboratory_V1_Task_1')
  9. title = models.CharField(max_length=50, verbose_name='测试任务标题')
  10. executor = models.ForeignKey(User, null=True, on_delete=models.CASCADE, verbose_name='测试任务执行者')
  11. # 0: 发布,release;(此阶段可以上传未执行的测试用例)1:执行测试用例,execute(此阶段需上传包含测试结果的测试用例);2:执行完成
  12. state = models.IntegerField(verbose_name='测试任务状态')
  13. description = models.TextField(verbose_name='测试任务描述')
  14. plan = models.ForeignKey(TestPlan, on_delete=models.CASCADE, verbose_name='测试任务所属计划')
  15. statement_file = models.TextField(verbose_name='说明文档id文件')
  16. case_file = models.TextField(null=True, verbose_name='测试用例文档')
  17. case_all = models.IntegerField(null=True, verbose_name='全部测试用例数量')
  18. case_not_execute = models.IntegerField(null=True, verbose_name='未执行测试用例数量')
  19. case_success = models.IntegerField(null=True, verbose_name='成功测试用例数量')
  20. case_fail = models.IntegerField(null=True, verbose_name='失败测试用例数量')
  21. create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
  22. update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
  23. delete = models.BooleanField(default=False)
  24. def __str__(self):
  25. return self.title
  26. class Meta:
  27. verbose_name = '测试任务'
  28. verbose_name_plural = verbose_name
  29. db_table = 'task'
  30. class TestCase(models.Model):
  31. id = models.CharField(max_length=30, unique=True, primary_key=True, verbose_name='测试用例编号',
  32. default='TestLaboratory_V1_Case_1')
  33. task = models.ForeignKey(TestTask, on_delete=models.CASCADE, verbose_name='测试用例所在测试任务',
  34. default='TestLaboratory_V1_Task_1')
  35. id_in_task = models.CharField(max_length=30, verbose_name='在测试任务中编号', default='1')
  36. software = models.ForeignKey(Software, null=True, on_delete=models.CASCADE, verbose_name='测试软件')
  37. executor_id = models.ForeignKey(User, null=True, on_delete=models.CASCADE, verbose_name='执行者id')
  38. version = models.CharField(max_length=30, null=True, verbose_name='软件版本')
  39. name = models.CharField(max_length=50, verbose_name='名称')
  40. state = models.IntegerField(verbose_name='状态')
  41. writer = models.CharField(max_length=30, verbose_name='测试用例编写人', null=True)
  42. executor = models.CharField(max_length=30, verbose_name='测试用例执行人', null=True)
  43. assessor = models.CharField(max_length=30, verbose_name='测试用例评审员', null=True)
  44. requisite = models.TextField(null=True, verbose_name='前置条件')
  45. priority = models.CharField(max_length=10, null=True, verbose_name='优先级')
  46. environment = models.TextField(null=True, verbose_name='测试环境')
  47. type = models.CharField(max_length=30, null=True, verbose_name='测试类型')
  48. process = models.TextField(verbose_name='测试步骤')
  49. expected_result = models.TextField(verbose_name='预期结果')
  50. actual_result = models.TextField(verbose_name='实际结果', null=True)
  51. create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
  52. update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
  53. delete = models.BooleanField(default=False)
  54. remark = models.TextField(null=True, verbose_name='备注')
  55. def __str__(self):
  56. return self.name
  57. class Meta:
  58. verbose_name = '测试用例'
  59. verbose_name_plural = verbose_name
  60. db_table = 'test_case'