-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
69 lines (55 loc) · 2.42 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from django.db import models
from qualitio.core.custommodel.models import ModelCustomization
from django.core.exceptions import ValidationError
# import store models
from qualitio.store.models import TestCaseDirectory, TestCase
# import execute models
from qualitio.execute.models import TestRun
class MeegoTestCaseDirectory(ModelCustomization):
is_suite = models.BooleanField(default=False)
def clean_origin(self):
for ancestor in self.origin.get_ancestors():
if ancestor.customization.is_suite:
raise ValidationError('Parent directory is already a suite')
class Meta:
model = TestCaseDirectory
class MeegoTestCase(ModelCustomization):
FEATURE_TYPE_CHOICES = (
('Basic', 'Basic'),
('Advanced', 'Advanced'),
)
feature_type = models.CharField(max_length=32, choices=FEATURE_TYPE_CHOICES, default='Basic')
def resolve_suite(self):
if self.origin.parent.customization.is_suite:
return self.origin.parent.name
for directory in self.origin.parent.get_ancestors():
if directory.customization.is_suite:
return directory.name
return "Test Suite" #default name
class Meta:
model = TestCase
class MeegoTestRun(ModelCustomization):
hwbuild = models.CharField(max_length=256, blank=True, null=True, verbose_name="SW Image")
hwproduct = models.CharField(max_length=256, blank=True, null=True, verbose_name="Hardware")
def calculate_set_name(self):
set_list = []
for test_case in self.origin.testcases.all():
set_list.append(test_case.origin.customization.feature_type)
if set_list:
return list(set(set_list))[0] #ToDo: change it later to sth better
return "Basic"
def calculate_suite_name(self):
"""Returns the suite name for the set of test cases"""
# ToDo: implement some simple algorithm that
# iterates through test case runs in the test run and
# checks the directory of the test case from store
# corresponding to the test case run
# for now returns string
suite_list = []
for test_case in self.origin.testcases.all():
suite_list.append(test_case.origin.customization.resolve_suite())
if suite_list:
return list(set(suite_list))[0] #ToDo: change it later to sth better
return "Test Suite"
class Meta:
model = TestRun