-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel.py
50 lines (38 loc) · 1.71 KB
/
model.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
import mongoengine
class Testcase(mongoengine.Document):
inclusionmethod = mongoengine.StringField( null=False, blank=False )
difference = mongoengine.StringField( null=False, blank=False )
filetype = mongoengine.StringField( null=False, blank=False )
browser = mongoengine.StringField( null=False, blank=False )
# the state of the resource to be included
includee_state = mongoengine.BooleanField( )
# from which config this test case was created
testsuite = mongoengine.StringField()
length = mongoengine.IntField()
duration = mongoengine.StringField()
time = mongoengine.StringField()
logs = mongoengine.StringField()
# This contains the whole result of the diff-algorithm as json
diff_results = mongoengine.DictField()
url = mongoengine.StringField()
diff_tags = mongoengine.ListField()
def switch_state(self):
self.includee_state = not self.includee_state
self.save()
def getName(self):
return f"{self.inclusionmethod}/{self.difference}/{self.filetype}/{self.browser}"
def __repr__(self):
return f"<Diff {self.getName()}>"
meta = {
'indexes': [
{ 'fields': ['inclusionmethod', 'difference', 'filetype', 'browser'], 'unique': True },
{ 'fields': ['-time'] },
{ 'fields': ['-length']},
{ 'fields': ['-inclusionmethod']},
{ 'fields': ['-difference']},
{ 'fields': ['-filetype']},
{ 'fields': ['-browser']}
],
'ordering': ['-time'],
'auto_create_index': True,
}