forked from rhevm-qe-automation/pytest_jira
-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue_model.py
80 lines (56 loc) · 2.07 KB
/
issue_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from marshmallow import Schema, fields, EXCLUDE
class Basic(Schema):
id = fields.String()
name = fields.String()
class Components(Schema):
name = fields.String()
class Version(Schema):
name = fields.String()
class Priority(Basic):
pass
class Resolution(Basic):
description = fields.String()
class Status(Basic):
description = fields.String()
class Type(Basic):
subtask = fields.Boolean()
class User(Schema):
key = fields.String()
name = fields.String()
displayName = fields.String()
active = fields.Boolean()
class JiraIssueSchema(Schema):
class Meta:
unknown = EXCLUDE # exclude unknown fields
# Default set to None for fields that are not filled
issuetype = fields.Nested(Type(), default=None)
status = fields.Nested(Status(), default=None)
priority = fields.Nested(Priority(), default=None)
reporter = fields.Nested(User(), default=None)
creator = fields.Nested(User(), default=None)
versions = fields.List(fields.Nested(Version()), default=None)
summary = fields.String(default=None)
updated = fields.String(default=None)
created = fields.String(default=None)
resolutiondate = fields.String(default=None)
duedate = fields.String(default=None)
fixVersions = fields.List(fields.Nested(Version()), default=None)
components = fields.List(fields.Nested(Components()), default=None)
resolution = fields.Nested(Resolution(), default=None)
assignee = fields.Nested(User(), default=None)
labels = fields.List(fields.String())
class JiraIssue:
def __init__(self, issue_id, **entries):
self.__dict__.update(entries)
self.issue_id = issue_id
def __repr__(self):
return 'JiraIssue {}'.format(self.issue_id)
@property
def components_list(self):
return set(component['name'] for component in self.components)
@property
def fixed_versions(self):
return set(version['name'] for version in self.fix_versions)
@property
def versions_list(self):
return set(version['name'] for version in self.versions)