models.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. company_id = models.IntegerField(verbose_name='公司id')
  25. def __str__(self):
  26. return self.title
  27. class Meta:
  28. verbose_name = '测试任务'
  29. verbose_name_plural = verbose_name
  30. db_table = 'task'
  31. class TestCase(models.Model):
  32. id = models.CharField(max_length=128, unique=True, primary_key=True, verbose_name='测试用例编号',
  33. default='TestLaboratory_V1_Case_1')
  34. task = models.ForeignKey(TestTask, on_delete=models.CASCADE, verbose_name='测试用例所在测试任务',
  35. default='TestLaboratory_V1_Task_1')
  36. id_in_task = models.CharField(max_length=30, verbose_name='在测试任务中编号', default='1')
  37. software = models.ForeignKey(Software, null=True, on_delete=models.CASCADE, verbose_name='测试软件')
  38. executor_id = models.ForeignKey(User, null=True, on_delete=models.CASCADE, verbose_name='执行者id')
  39. version = models.CharField(max_length=30, null=True, verbose_name='软件版本')
  40. name = models.CharField(max_length=50, verbose_name='名称')
  41. state = models.IntegerField(verbose_name='状态')
  42. writer = models.CharField(max_length=30, verbose_name='测试用例编写人', null=True)
  43. executor = models.CharField(max_length=30, verbose_name='测试用例执行人', null=True)
  44. assessor = models.CharField(max_length=30, verbose_name='测试用例评审员', null=True)
  45. requisite = models.TextField(null=True, verbose_name='前置条件')
  46. priority = models.CharField(max_length=10, null=True, verbose_name='优先级')
  47. environment = models.TextField(null=True, verbose_name='测试环境')
  48. type = models.CharField(max_length=30, null=True, verbose_name='测试类型')
  49. process = models.TextField(verbose_name='测试步骤')
  50. expected_result = models.TextField(verbose_name='预期结果')
  51. actual_result = models.TextField(verbose_name='实际结果', null=True)
  52. create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
  53. update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
  54. delete = models.BooleanField(default=False)
  55. remark = models.TextField(null=True, verbose_name='备注')
  56. def __str__(self):
  57. return self.name
  58. class Meta:
  59. verbose_name = '测试用例'
  60. verbose_name_plural = verbose_name
  61. db_table = 'test_case'