forked from allure-framework/allure-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.py
More file actions
161 lines (118 loc) · 4.01 KB
/
result.py
File metadata and controls
161 lines (118 loc) · 4.01 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""
>>> from hamcrest import assert_that
>>> from hamcrest import is_not
>>> testcases = {
... 'ideal_case': {
... 'name': 'ideal_case',
... 'parentIds': ['gid-1', 'gid-2'],
... 'steps': [
... {'name': 'step_one'}
... ]
... },
... 'like_ideal_case_by_group': {
... 'name': 'like_ideal_case_by_group',
... 'parentIds': ['gid-1', 'gid-2'],
... },
... 'has_wrong_group_case': {
... 'name': 'anoher_case',
... 'parentIds': ['gid-1', 'gid-3'],
... }
... }
>>> testgroups = {
... 'gid-1': {
... 'id': 'gid-1',
... 'befores': [
... {'name': 'before_#1_gid1'},
... {'name': 'before_#2_gid1'}
... ]
... },
... 'gid-2': {
... 'id': 'gid-2'
... }
... }
>>> assert_that(testcases['ideal_case'], has_step('step_one'))
>>> assert_that(testcases['ideal_case'],
... has_step('ideal_case'),
... is_not(has_step('step_one'))
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expected: ...
but: ...
<BLANKLINE>
>>> assert_that(testcases['ideal_case'],
... has_step('wrong_step_name')
... ) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
AssertionError: ...
Expected: ...
but: ...
<BLANKLINE>
"""
from hamcrest import all_of, anything, not_
from hamcrest import equal_to, not_none
from hamcrest import has_entry, has_item
from hamcrest import contains_string, starts_with
def has_title(title):
return has_entry('name', title)
def has_description(*matchers):
return has_entry('description', all_of(*matchers))
def has_description_html(*matchers):
return has_entry('descriptionHtml', all_of(*matchers))
def has_step(name, *matchers):
return has_entry('steps',
has_item(
all_of(
has_entry('name', equal_to(name)),
*matchers
)
))
def has_parameter(name, value):
return has_entry('parameters',
has_item(
all_of(
has_entry('name', equal_to(name)),
has_entry('value', equal_to(value))
)
))
def doesnt_have_parameter(name):
return has_entry('parameters',
not_(
has_item(
has_entry('name', equal_to(name)),
)))
def has_link(url, link_type=None, name=None):
return has_entry('links',
has_item(
all_of(
*[has_entry(key, value) for key, value in
zip(('url', 'type', 'name'), (url, link_type, name)) if value is not None]
)
))
def has_issue_link(url, name=None):
return has_link(url, link_type='issue', name=name)
def has_test_case_link(url, name=None):
return has_link(url, link_type='test_case', name=name)
def has_attachment(attach_type=None, name=None):
return has_entry('attachments',
has_item(
all_of(
has_entry('source', anything()),
has_entry('type', attach_type) if attach_type else anything(),
has_entry('name', name) if name else anything()
)
))
def with_id():
return has_entry('uuid', not_none())
def with_status(status):
return has_entry('status', status)
def has_status_details(*matchers):
return has_entry('statusDetails', all_of(*matchers))
def with_message_contains(string):
return has_entry('message', contains_string(string))
def with_trace_contains(string):
return has_entry('trace', contains_string(string))
def has_history_id():
return has_entry('historyId', anything())