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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
from report_tools import (
card_blueprints,
card_blueprints_by_status,
)
card_health_checks = []
def register_health_check(cls):
card_health_checks.append(cls)
return cls
class HealthCheck(object):
NOT_APPLICABLE = 'n/a'
OK = 'OK'
NOT_OK = 'Not OK'
name = 'Base check, not to be used'
@classmethod
def applicable(cls, card, store=None):
raise NotImplementedError()
@classmethod
def check(cls, card, store=None):
raise NotImplementedError()
@classmethod
def execute(cls, card, store=None):
if cls.applicable(card, store):
if cls.check(card, store):
return cls.OK
else:
return cls.NOT_OK
else:
return cls.NOT_APPLICABLE
@register_health_check
class DescriptionHealthCheck(HealthCheck):
name = 'Has description'
@classmethod
def applicable(cls, card, store=None):
return True
@classmethod
def check(cls, card, store=None):
return card.description is not None
@register_health_check
class CriteriaHealthCheck(HealthCheck):
name = 'Has acceptance criteria'
@classmethod
def applicable(cls, card, store=None):
return True
@classmethod
def check(cls, card, store=None):
return card.acceptance_criteria is not None
@register_health_check
class BlueprintsHealthCheck(HealthCheck):
name = 'Has blueprints'
@classmethod
def applicable(cls, card, store):
return card.status == 'Ready'
@classmethod
def check(cls, card, store):
return len(card_blueprints(store, card.roadmap_id)) > 0
@register_health_check
class BlueprintsBlockedHealthCheck(HealthCheck):
name = 'Has no Blocked blueprints'
@classmethod
def applicable(cls, card, store):
return card.status != 'Ready'
@classmethod
def check(cls, card, store):
blueprints = card_blueprints_by_status(store, card.roadmap_id)
return len(blueprints['Blocked']) == 0
@register_health_check
class RoadmapIdHealthCheck(HealthCheck):
name = 'Has a roadmap id'
@classmethod
def applicable(cls, card, store=None):
return True
@classmethod
def check(cls, card, store=None):
return card.roadmap_id != ''
|