line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestRail::API; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$TestRail::API::VERSION = '0.007'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
TestRail::API - Provides an interface to TestRail's REST api via HTTP |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use TestRail::API; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $tr = TestRail::API->new($username, $password, $host); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C provides methods to access an existing TestRail account using API v2. You can then do things like look up tests, set statuses and create runs from lists of cases. |
19
|
|
|
|
|
|
|
It is by no means exhaustively implementing every TestRail API function. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
1218
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
25
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
26
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
80
|
|
27
|
1
|
|
|
1
|
|
5
|
use Scalar::Util 'reftype'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
294
|
|
28
|
1
|
|
|
1
|
|
1377
|
use Clone 'clone'; |
|
1
|
|
|
|
|
18969
|
|
|
1
|
|
|
|
|
330
|
|
29
|
1
|
|
|
1
|
|
2454
|
use Try::Tiny; |
|
1
|
|
|
|
|
2665
|
|
|
1
|
|
|
|
|
70
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
1395
|
use JSON::XS; |
|
1
|
|
|
|
|
124882
|
|
|
1
|
|
|
|
|
120
|
|
32
|
1
|
|
|
1
|
|
1310
|
use HTTP::Request; |
|
1
|
|
|
|
|
232846
|
|
|
1
|
|
|
|
|
56
|
|
33
|
1
|
|
|
1
|
|
4373
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
62131
|
|
|
1
|
|
|
|
|
4133
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 B |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates new C object. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item STRING C - base url for your TestRail api server. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item STRING C - Your testRail User. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item STRING C - Your TestRail password. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item BOOLEAN C - Print the JSON responses from TL with your requests. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns C object if login is successful. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $tr = TestRail::API->new('http://tr.test/testrail', 'moo','M000000!'); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
60
|
0
|
|
|
0
|
1
|
|
my ($class,$apiurl,$user,$pass,$debug) = @_; |
61
|
0
|
|
0
|
|
|
|
$user //= $ENV{'TESTRAIL_USER'}; |
62
|
0
|
|
0
|
|
|
|
$pass //= $ENV{'TESTRAIL_PASSWORD'}; |
63
|
0
|
|
0
|
|
|
|
$debug //= 0; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $self = { |
66
|
|
|
|
|
|
|
user => $user, |
67
|
|
|
|
|
|
|
pass => $pass, |
68
|
|
|
|
|
|
|
apiurl => $apiurl, |
69
|
|
|
|
|
|
|
debug => $debug, |
70
|
|
|
|
|
|
|
testtree => [], |
71
|
|
|
|
|
|
|
flattree => [], |
72
|
|
|
|
|
|
|
user_cache => [], |
73
|
|
|
|
|
|
|
type_cache => [], |
74
|
|
|
|
|
|
|
default_request => undef, |
75
|
|
|
|
|
|
|
browser => new LWP::UserAgent() |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#Create default request to pass on to LWP::UserAgent |
79
|
0
|
|
|
|
|
|
$self->{'default_request'} = new HTTP::Request(); |
80
|
0
|
|
|
|
|
|
$self->{'default_request'}->authorization_basic($user,$pass); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
bless $self, $class; |
83
|
0
|
|
|
|
|
|
return $self; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#EZ access of obj vars |
87
|
0
|
|
|
0
|
0
|
|
sub browser {$_[0]->{'browser'}} |
88
|
0
|
|
|
0
|
0
|
|
sub apiurl {$_[0]->{'apiurl'}} |
89
|
0
|
|
|
0
|
0
|
|
sub debug {$_[0]->{'debug'}} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#Convenient JSON-HTTP fetcher |
92
|
|
|
|
|
|
|
sub _doRequest { |
93
|
0
|
|
|
0
|
|
|
my ($self,$path,$method,$data) = @_; |
94
|
0
|
|
|
|
|
|
my $req = clone $self->{'default_request'}; |
95
|
0
|
|
0
|
|
|
|
$method //= 'GET'; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$req->method($method); |
98
|
0
|
|
|
|
|
|
$req->url($self->apiurl.'/'.$path); |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
warn "$method ".$self->apiurl."/$path" if $self->debug; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#Data sent is JSON |
103
|
0
|
0
|
|
|
|
|
my $content = $data ? encode_json($data) : ''; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$req->content($content); |
106
|
0
|
|
|
|
|
|
$req->header( "Content-Type" => "application/json" ); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $response = $self->browser->request($req); |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
if ($response->code == 403) { |
111
|
0
|
|
|
|
|
|
warn "ERROR: Access Denied."; |
112
|
0
|
|
|
|
|
|
return 0; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
0
|
|
|
|
|
if ($response->code != 200) { |
115
|
0
|
|
|
|
|
|
warn "ERROR: Arguments Bad: ".$response->content; |
116
|
0
|
|
|
|
|
|
return 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
try { |
120
|
0
|
|
|
0
|
|
|
return decode_json($response->content); |
121
|
|
|
|
|
|
|
} catch { |
122
|
0
|
0
|
0
|
0
|
|
|
if ($response->code == 200 && !$response->content) { |
123
|
0
|
|
|
|
|
|
return 1; #This function probably just returns no data |
124
|
|
|
|
|
|
|
} else { |
125
|
0
|
|
|
|
|
|
warn "ERROR: Malformed JSON returned by API."; |
126
|
0
|
|
|
|
|
|
warn $@; |
127
|
0
|
0
|
|
|
|
|
if (!$self->debug) { #Otherwise we've already printed this, but we need to know if we encounter this |
128
|
0
|
|
|
|
|
|
warn "RAW CONTENT:"; |
129
|
0
|
|
|
|
|
|
warn $response->content |
130
|
|
|
|
|
|
|
} |
131
|
0
|
|
|
|
|
|
return 0; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
0
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 USER METHODS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 B |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Get all the user definitions for the provided Test Rail install. |
141
|
|
|
|
|
|
|
Returns ARRAYREF of user definition HASHREFs. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub getUsers { |
146
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
147
|
0
|
|
|
|
|
|
$self->{'user_cache'} = $self->_doRequest('index.php?/api/v2/get_users'); |
148
|
0
|
|
|
|
|
|
return $self->{'user_cache'}; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 B |
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
=head2 B |
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
=head2 B |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get user definition hash by ID, Name or Email. |
158
|
|
|
|
|
|
|
Returns user def HASHREF. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
#I'm just using the cache for the following methods because it's more straightforward and faster past 1 call. |
164
|
|
|
|
|
|
|
sub getUserByID { |
165
|
0
|
|
|
0
|
1
|
|
my ($self,$user) = @_; |
166
|
0
|
0
|
|
|
|
|
$self->getUsers() if (!scalar(@{$self->{'user_cache'}})); |
|
0
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
foreach my $usr (@{$self->{'user_cache'}}) { |
|
0
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
return $usr if $usr->{'id'} == $user; |
170
|
|
|
|
|
|
|
} |
171
|
0
|
|
|
|
|
|
return 0; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub getUserByName { |
175
|
0
|
|
|
0
|
1
|
|
my ($self,$user) = @_; |
176
|
0
|
0
|
|
|
|
|
$self->getUsers() if (!scalar(@{$self->{'user_cache'}})); |
|
0
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
foreach my $usr (@{$self->{'user_cache'}}) { |
|
0
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
return $usr if $usr->{'name'} eq $user; |
179
|
|
|
|
|
|
|
} |
180
|
0
|
|
|
|
|
|
return 0; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub getUserByEmail { |
184
|
0
|
|
|
0
|
1
|
|
my ($self,$user) = @_; |
185
|
0
|
0
|
|
|
|
|
$self->getUsers() if (!scalar(@{$self->{'user_cache'}})); |
|
0
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
foreach my $usr (@{$self->{'user_cache'}}) { |
|
0
|
|
|
|
|
|
|
187
|
0
|
0
|
|
|
|
|
return $usr if $usr->{'email'} eq $user; |
188
|
|
|
|
|
|
|
} |
189
|
0
|
|
|
|
|
|
return 0; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 PROJECT METHODS |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 B |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Creates new Project (Database of testsuites/tests). |
197
|
|
|
|
|
|
|
Optionally specify an announcement to go out to the users. |
198
|
|
|
|
|
|
|
Requires TestRail admin login. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=over 4 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item STRING C - Desired name of project. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item STRING C (optional) - Description of project. Default value is 'res ipsa loquiter'. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item BOOLEAN C (optional) - Whether to confront users with an announcement about your awesome project on next login. Default false. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=back |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Returns project definition HASHREF on success, false otherwise. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
$tl->createProject('Widgetronic 4000', 'Tests for the whiz-bang new product', true); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub createProject { |
217
|
0
|
|
|
0
|
1
|
|
my ($self,$name,$desc,$announce) = @_; |
218
|
0
|
|
0
|
|
|
|
$desc //= 'res ipsa loquiter'; |
219
|
0
|
|
0
|
|
|
|
$announce //= 0; |
220
|
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
|
my $input = { |
222
|
|
|
|
|
|
|
name => $name, |
223
|
|
|
|
|
|
|
announcement => $desc, |
224
|
|
|
|
|
|
|
show_announcement => $announce ? Types::Serialiser::true : Types::Serialiser::false |
225
|
|
|
|
|
|
|
}; |
226
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/add_project','POST',$input); |
228
|
0
|
|
|
|
|
|
return $result; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 B |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Deletes specified project by ID. |
235
|
|
|
|
|
|
|
Requires TestRail admin login. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=over 4 |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item STRING C - Desired name of project. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=back |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Returns BOOLEAN. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
$success = $tl->deleteProject(1); |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub deleteProject { |
250
|
0
|
|
|
0
|
0
|
|
my ($self,$proj) = @_; |
251
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/delete_project/'.$proj,'POST'); |
252
|
0
|
|
|
|
|
|
return $result; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 B |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Get all available projects |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Returns array of project definition HASHREFs, false otherwise. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
$projects = $tl->getProjects; |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=cut |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub getProjects { |
266
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/get_projects'); |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
#Save state for future use, if needed |
271
|
0
|
0
|
|
|
|
|
if (!scalar(@{$self->{'testtree'}})) { |
|
0
|
|
|
|
|
|
|
272
|
0
|
0
|
|
|
|
|
$self->{'testtree'} = $result if $result; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
0
|
0
|
|
|
|
|
if ($result) { |
276
|
|
|
|
|
|
|
#Note that it's a project for future reference by recursive tree search |
277
|
0
|
|
|
|
|
|
for my $pj (@{$result}) { |
|
0
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
$pj->{'type'} = 'project'; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
return $result; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head2 B |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Gets some project definition hash by it's name |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=over 4 |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item STRING C - desired project |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=back |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
Returns desired project def HASHREF, false otherwise. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
$projects = $tl->getProjectByName('FunProject'); |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=cut |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
sub getProjectByName { |
302
|
0
|
|
|
0
|
1
|
|
my ($self,$project) = @_; |
303
|
0
|
0
|
|
|
|
|
confess "No project provided." unless $project; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
#See if we already have the project list... |
306
|
0
|
|
|
|
|
|
my $projects = $self->{'testtree'}; |
307
|
0
|
0
|
|
|
|
|
$projects = $self->getProjects() unless scalar(@$projects); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
#Search project list for project |
310
|
0
|
|
|
|
|
|
for my $candidate (@$projects) { |
311
|
0
|
0
|
|
|
|
|
return $candidate if ($candidate->{'name'} eq $project); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
0
|
|
|
|
|
|
return 0; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 B |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
Gets some project definition hash by it's ID |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=over 4 |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=item INTEGER C - desired project |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=back |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
Returns desired project def HASHREF, false otherwise. |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
$projects = $tl->getProjectByID(222); |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub getProjectByID { |
334
|
0
|
|
|
0
|
1
|
|
my ($self,$project) = @_; |
335
|
0
|
0
|
|
|
|
|
confess "No project provided." unless $project; |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
#See if we already have the project list... |
338
|
0
|
|
|
|
|
|
my $projects = $self->{'testtree'}; |
339
|
0
|
0
|
|
|
|
|
$projects = $self->getProjects() unless scalar(@$projects); |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
#Search project list for project |
342
|
0
|
|
|
|
|
|
for my $candidate (@$projects) { |
343
|
0
|
0
|
|
|
|
|
return $candidate if ($candidate->{'id'} eq $project); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
0
|
|
|
|
|
|
return 0; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
=head1 TESTSUITE METHODS |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=head2 B |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
Creates new TestSuite (folder of tests) in the database of test specifications under given project id having given name and details. |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=over 4 |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=item INTEGER C - ID of project this test suite should be under. |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=item STRING C - Desired name of test suite. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=item STRING C (optional) - Description of test suite. Default value is 'res ipsa loquiter'. |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=back |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Returns TS definition HASHREF on success, false otherwise. |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
$tl->createTestSuite(1, 'broken tests', 'Tests that should be reviewed'); |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=cut |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
sub createTestSuite { |
371
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$name,$details) = @_; |
372
|
0
|
|
0
|
|
|
|
$details ||= 'res ipsa loquiter'; |
373
|
|
|
|
|
|
|
|
374
|
0
|
|
|
|
|
|
my $input = { |
375
|
|
|
|
|
|
|
name => $name, |
376
|
|
|
|
|
|
|
description => $details |
377
|
|
|
|
|
|
|
}; |
378
|
|
|
|
|
|
|
|
379
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/add_suite/'.$project_id,'POST',$input); |
380
|
0
|
|
|
|
|
|
return $result; |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=head2 B |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
Deletes specified testsuite. |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=over 4 |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=item INTEGER C - ID of testsuite to delete. |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=back |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Returns BOOLEAN. |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
$tl->deleteTestSuite(1); |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=cut |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
sub deleteTestSuite { |
401
|
0
|
|
|
0
|
1
|
|
my ($self,$suite_id) = @_; |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/delete_suite/'.$suite_id,'POST'); |
404
|
0
|
|
|
|
|
|
return $result; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=head2 B |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Gets the testsuites for a project |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=over 4 |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
=item STRING C - desired project's ID |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
=back |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
Returns ARRAYREF of testsuite definition HASHREFs, 0 on error. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
$suites = $tl->getTestSuites(123); |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=cut |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub getTestSuites { |
425
|
0
|
|
|
0
|
1
|
|
my ($self,$proj) = @_; |
426
|
0
|
|
|
|
|
|
return $self->_doRequest('index.php?/api/v2/get_suites/'.$proj); |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=head2 B |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
Gets the testsuite that matches the given name inside of given project. |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=over 4 |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=item STRING C - ID of project holding this testsuite |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=item STRING C - desired parent testsuite name |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=back |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
Returns desired testsuite definition HASHREF, false otherwise. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
$suites = $tl->getTestSuitesByName(321, 'hugSuite'); |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=cut |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub getTestSuiteByName { |
448
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$testsuite_name) = @_; |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
#TODO cache |
451
|
0
|
|
|
|
|
|
my $suites = $self->getTestSuites($project_id); |
452
|
0
|
0
|
|
|
|
|
return 0 if !$suites; #No suites for project, or no project |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
foreach my $suite (@$suites) { |
455
|
0
|
0
|
|
|
|
|
return $suite if $suite->{'name'} eq $testsuite_name; |
456
|
|
|
|
|
|
|
} |
457
|
0
|
|
|
|
|
|
return 0; #Couldn't find it |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=head2 B |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
Gets the testsuite with the given ID. |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
=over 4 |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=item STRING C - Testsuite ID. |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=back |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
Returns desired testsuite definition HASHREF, false otherwise. |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
$tests = $tl->getTestSuiteByID(123); |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=cut |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
sub getTestSuiteByID { |
477
|
0
|
|
|
0
|
1
|
|
my ($self,$testsuite_id) = @_; |
478
|
|
|
|
|
|
|
|
479
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/get_suite/'.$testsuite_id); |
480
|
0
|
|
|
|
|
|
return $result; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=head1 SECTION METHODS |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=head2 B |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
Creates a section. |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=over 4 |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=item INTEGER C - Parent Project ID. |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=item INTEGER C - Parent Testsuite ID. |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=item STRING C - desired section name. |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=item INTEGER C (optional) - parent section id |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=back |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
Returns new section definition HASHREF, false otherwise. |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
$section = $tr->createSection(1,1,'nugs',1); |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=cut |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
sub createSection { |
508
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id,$name,$parent_id) = @_; |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
my $input = { |
511
|
|
|
|
|
|
|
name => $name, |
512
|
|
|
|
|
|
|
suite_id => $suite_id |
513
|
|
|
|
|
|
|
}; |
514
|
0
|
0
|
|
|
|
|
$input->{'parent_id'} = $parent_id if $parent_id; |
515
|
|
|
|
|
|
|
|
516
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/add_section/'.$project_id,'POST',$input); |
517
|
0
|
|
|
|
|
|
return $result; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
} |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=head2 B |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
Deletes specified section. |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=over 4 |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=item INTEGER C - ID of section to delete. |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=back |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
Returns BOOLEAN. |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
$tr->deleteSection(1); |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=cut |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
sub deleteSection { |
538
|
0
|
|
|
0
|
1
|
|
my ($self,$section_id) = @_; |
539
|
|
|
|
|
|
|
|
540
|
0
|
|
|
|
|
|
my $result = $self->_doRequest('index.php?/api/v2/delete_section/'.$section_id,'POST'); |
541
|
0
|
|
|
|
|
|
return $result; |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
=head2 B |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Gets sections for a given project and suite. |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=over 4 |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=item INTEGER C - ID of suite to get sections for. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=back |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
Returns ARRAYREF of section definition HASHREFs. |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
$tr->getSections(1,2); |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=cut |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
sub getSections { |
564
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id) = @_; |
565
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_sections/$project_id&suite_id=$suite_id"); |
566
|
|
|
|
|
|
|
} |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
=head2 B |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
Gets desired section. |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=over 4 |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=item INTEGER C - ID of suite to get sections for. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=back |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
Returns section definition HASHREF. |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
$tr->getSectionByID(344); |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
=cut |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
sub getSectionByID { |
587
|
0
|
|
|
0
|
1
|
|
my ($self,$section_id) = @_; |
588
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_section/$section_id"); |
589
|
|
|
|
|
|
|
} |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=head2 B |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
Gets desired section. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=over 4 |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=item INTEGER C - ID of suite to get section for. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=item STRING C - name of section to get |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=back |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
Returns section definition HASHREF. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
$tr->getSectionByName(1,2,'nugs'); |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=cut |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
sub getSectionByName { |
612
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id,$section_name) = @_; |
613
|
0
|
|
|
|
|
|
my $sections = $self->getSections($project_id,$suite_id); |
614
|
0
|
|
|
|
|
|
foreach my $sec (@$sections) { |
615
|
0
|
0
|
|
|
|
|
return $sec if $sec->{'name'} eq $section_name; |
616
|
|
|
|
|
|
|
} |
617
|
0
|
|
|
|
|
|
return 0; |
618
|
|
|
|
|
|
|
} |
619
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
=head1 CASE METHODS |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=head2 B |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
Gets possible case types. |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
Returns ARRAYREF of case type definition HASHREFs. |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
$tr->getCaseTypes(); |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=cut |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
sub getCaseTypes { |
633
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
634
|
0
|
0
|
|
|
|
|
$self->{'type_cache'} = $self->_doRequest("index.php?/api/v2/get_case_types") if !$self->type_cache; #We can't change this with API, so assume it is static |
635
|
0
|
|
|
|
|
|
return $self->{'type_cache'}; |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
=head2 B |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
Gets case type by name. |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
=over 4 |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=item STRING C - Name of desired case type |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
=back |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
Returns case type definition HASHREF. |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
$tr->getCaseTypeByName(); |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
=cut |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
sub getCaseTypeByName { |
655
|
|
|
|
|
|
|
#Useful for marking automated tests, etc |
656
|
0
|
|
|
0
|
1
|
|
my ($self,$name) = @_; |
657
|
0
|
|
|
|
|
|
my $types = $self->getCaseTypes(); |
658
|
0
|
|
|
|
|
|
foreach my $type (@$types) { |
659
|
0
|
0
|
|
|
|
|
return $type if $type->{'name'} eq $name; |
660
|
|
|
|
|
|
|
} |
661
|
0
|
|
|
|
|
|
return 0; |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=head2 B |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
Creates a test case. |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=over 4 |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=item INTEGER C |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=item STRING C - Case title. |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=item INTEGER C - desired test type's ID. |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=item HASHREF C (optional) - Custom fields in the case are the keys, set to the values provided. See TestRail API documentation for more info. |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=item HASHREF C (optional) - contains priority_id, estimate, milestone_id and refs as possible keys. See TestRail API documentation for more info. |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=back |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
Returns new case definition HASHREF, false otherwise. |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
$custom_opts = { |
685
|
|
|
|
|
|
|
preconds => "Test harness installed", |
686
|
|
|
|
|
|
|
steps => "Do the needful", |
687
|
|
|
|
|
|
|
expected => "cubicle environment transforms into Dali painting" |
688
|
|
|
|
|
|
|
}; |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
$other_opts = { |
691
|
|
|
|
|
|
|
priority_id => 4, |
692
|
|
|
|
|
|
|
milestone_id => 666, |
693
|
|
|
|
|
|
|
estimate => '2m 45s', |
694
|
|
|
|
|
|
|
refs => ['TRACE-22','ON-166'] #ARRAYREF of bug IDs. |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
$case = $tr->createCase(1,'Do some stuff',3,$custom_opts,$other_opts); |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=cut |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
sub createCase { |
702
|
0
|
|
|
0
|
1
|
|
my ($self,$section_id,$title,$type_id,$opts,$extras) = @_; |
703
|
|
|
|
|
|
|
|
704
|
0
|
|
|
|
|
|
my $stuff = { |
705
|
|
|
|
|
|
|
title => $title, |
706
|
|
|
|
|
|
|
type_id => $type_id |
707
|
|
|
|
|
|
|
}; |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
#Handle sort of optional but baked in options |
710
|
0
|
0
|
0
|
|
|
|
if (defined($extras) && reftype($extras) eq 'HASH') { |
711
|
0
|
0
|
|
|
|
|
$stuff->{'priority_id'} = $extras->{'priority_id'} if defined($extras->{'priority_id'}); |
712
|
0
|
0
|
|
|
|
|
$stuff->{'estimate'} = $extras->{'estimate'} if defined($extras->{'estimate'}); |
713
|
0
|
0
|
|
|
|
|
$stuff->{'milestone_id'} = $extras->{'milestone_id'} if defined($extras->{'milestone_id'}); |
714
|
0
|
0
|
|
|
|
|
$stuff->{'refs'} = join(',',@{$extras->{'refs'}}) if defined($extras->{'refs'}); |
|
0
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
#Handle custom fields |
718
|
0
|
0
|
0
|
|
|
|
if (defined($opts) && reftype($opts) eq 'HASH') { |
719
|
0
|
|
|
|
|
|
foreach my $key (keys(%$opts)) { |
720
|
0
|
|
|
|
|
|
$stuff->{"custom_$key"} = $opts->{$key}; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
} |
723
|
|
|
|
|
|
|
|
724
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/add_case/$section_id",'POST',$stuff); |
725
|
0
|
|
|
|
|
|
return $result; |
726
|
|
|
|
|
|
|
} |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
=head2 B |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
Deletes specified section. |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=over 4 |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=item INTEGER C - ID of case to delete. |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
=back |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
Returns BOOLEAN. |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
$tr->deleteCase(1324); |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
=cut |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
sub deleteCase { |
745
|
0
|
|
|
0
|
1
|
|
my ($self,$case_id) = @_; |
746
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/delete_case/$case_id",'POST'); |
747
|
0
|
|
|
|
|
|
return $result; |
748
|
|
|
|
|
|
|
} |
749
|
|
|
|
|
|
|
|
750
|
|
|
|
|
|
|
=head2 B |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
Gets cases for provided section. |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=over 4 |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
=item INTEGER C - ID of parent suite. |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
=item INTEGER C |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=back |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
Returns ARRAYREF of test case definition HASHREFs. |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
$tr->getCases(1,2,3); |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
=cut |
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
sub getCases { |
771
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id,$section_id) = @_; |
772
|
0
|
|
|
|
|
|
my $url = "index.php?/api/v2/get_cases/$project_id&suite_id=$suite_id"; |
773
|
0
|
0
|
|
|
|
|
$url .= "§ion_id=$section_id" if $section_id; |
774
|
0
|
|
|
|
|
|
return $self->_doRequest($url); |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
|
777
|
|
|
|
|
|
|
=head2 B |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
Gets case by name. |
780
|
|
|
|
|
|
|
|
781
|
|
|
|
|
|
|
=over 4 |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
=item INTEGER C - ID of parent suite. |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
=item INTEGER C |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
=item STRING - Name of desired test case. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=back |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
Returns test case definition HASHREF. |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
$tr->getCaseByName(1,2,3,'nugs'); |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
=cut |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
sub getCaseByName { |
800
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id,$section_id,$name) = @_; |
801
|
0
|
|
|
|
|
|
my $cases = $self->getCases($project_id,$suite_id,$section_id); |
802
|
0
|
|
|
|
|
|
foreach my $case (@$cases) { |
803
|
0
|
0
|
|
|
|
|
return $case if $case->{'title'} eq $name; |
804
|
|
|
|
|
|
|
} |
805
|
0
|
|
|
|
|
|
return 0; |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
=head2 B |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
Gets case by ID. |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
=over 4 |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
=item INTEGER C - ID of case. |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
=back |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
Returns test case definition HASHREF. |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
$tr->getCaseByID(1345); |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
=cut |
823
|
|
|
|
|
|
|
|
824
|
|
|
|
|
|
|
sub getCaseByID { |
825
|
0
|
|
|
0
|
1
|
|
my ($self,$case_id) = @_; |
826
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_case/$case_id"); |
827
|
|
|
|
|
|
|
} |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=head1 RUN METHODS |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=head2 B |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
Create a run. |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
=over 4 |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=item INTEGER C - ID of suite to base run on |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=item STRING C - Name of run |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=item STRING C (optional) - Description of run |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=item INTEGER C (optional) - ID of milestone |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
=item INTEGER C (optional) - User to assign the run to |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=item ARRAYREF C (optional) - Array of case IDs in case you don't want to use the whole testsuite when making the build. |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
=back |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
Returns run definition HASHREF. |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
$tr->createRun(1,1345,'RUN AWAY','SO FAR AWAY',22,3,[3,4,5,6]); |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=cut |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
#If you pass an array of case ids, it implies include_all is false |
860
|
|
|
|
|
|
|
sub createRun { |
861
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$suite_id,$name,$desc,$milestone_id,$assignedto_id,$case_ids) = @_; |
862
|
|
|
|
|
|
|
|
863
|
0
|
0
|
|
|
|
|
my $stuff = { |
864
|
|
|
|
|
|
|
suite_id => $suite_id, |
865
|
|
|
|
|
|
|
name => $name, |
866
|
|
|
|
|
|
|
description => $desc, |
867
|
|
|
|
|
|
|
milestone_id => $milestone_id, |
868
|
|
|
|
|
|
|
assignedto_id => $assignedto_id, |
869
|
|
|
|
|
|
|
include_all => $case_ids ? Types::Serialiser::false : Types::Serialiser::true, |
870
|
|
|
|
|
|
|
case_ids => $case_ids |
871
|
|
|
|
|
|
|
}; |
872
|
|
|
|
|
|
|
|
873
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/add_run/$project_id",'POST',$stuff); |
874
|
0
|
|
|
|
|
|
return $result; |
875
|
|
|
|
|
|
|
} |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
=head2 B |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
Deletes specified run. |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
=over 4 |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
=item INTEGER C - ID of run to delete. |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
=back |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
Returns BOOLEAN. |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
$tr->deleteRun(1324); |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
=cut |
892
|
|
|
|
|
|
|
|
893
|
|
|
|
|
|
|
sub deleteRun { |
894
|
0
|
|
|
0
|
1
|
|
my ($self,$suite_id) = @_; |
895
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/delete_run/$suite_id",'POST'); |
896
|
0
|
|
|
|
|
|
return $result; |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
=head2 B |
900
|
|
|
|
|
|
|
|
901
|
|
|
|
|
|
|
Gets run by name. |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
=over 4 |
904
|
|
|
|
|
|
|
|
905
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
906
|
|
|
|
|
|
|
|
907
|
|
|
|
|
|
|
=item STRING - Name of desired run. |
908
|
|
|
|
|
|
|
|
909
|
|
|
|
|
|
|
=back |
910
|
|
|
|
|
|
|
|
911
|
|
|
|
|
|
|
Returns run definition HASHREF. |
912
|
|
|
|
|
|
|
|
913
|
|
|
|
|
|
|
$tr->getRunByName(1,'gravy'); |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
=cut |
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
sub getRuns { |
918
|
0
|
|
|
0
|
0
|
|
my ($self,$project_id) = @_; |
919
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_runs/$project_id"); |
920
|
|
|
|
|
|
|
} |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
sub getRunByName { |
923
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$name) = @_; |
924
|
0
|
|
|
|
|
|
my $runs = $self->getRuns($project_id); |
925
|
0
|
|
|
|
|
|
foreach my $run (@$runs) { |
926
|
0
|
0
|
|
|
|
|
return $run if $run->{'name'} eq $name; |
927
|
|
|
|
|
|
|
} |
928
|
0
|
|
|
|
|
|
return 0; |
929
|
|
|
|
|
|
|
} |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
=head2 B |
932
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
Gets run by ID. |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
=over 4 |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
=item INTEGER C - ID of desired run. |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
=back |
940
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
Returns run definition HASHREF. |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
$tr->getRunByID(7779311); |
944
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
=cut |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
sub getRunByID { |
948
|
0
|
|
|
0
|
1
|
|
my ($self,$run_id) = @_; |
949
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_run/$run_id"); |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
=head1 PLAN METHODS |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
=head2 B |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
Create a run. |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
=over 4 |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
=item STRING C - Name of plan |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
=item STRING C (optional) - Description of plan |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
=item INTEGER C (optional) - ID of milestone |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
=item ARRAYREF C (optional) - New Runs to initially populate the plan with -- See TestLink API documentation for more advanced inputs here. |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
=back |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
Returns test plan definition HASHREF, or false on failure. |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
$entries = { |
975
|
|
|
|
|
|
|
suite_id => 345, |
976
|
|
|
|
|
|
|
include_all => Types::Serialiser::true, |
977
|
|
|
|
|
|
|
assignedto_id => 1 |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
|
980
|
|
|
|
|
|
|
$tr->createPlan(1,'Gosplan','Robo-Signed Soviet 5-year plan',22,$entries); |
981
|
|
|
|
|
|
|
|
982
|
|
|
|
|
|
|
=cut |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
sub createPlan { |
985
|
0
|
|
|
0
|
0
|
|
my ($self,$project_id,$name,$desc,$milestone_id,$entries) = @_; |
986
|
|
|
|
|
|
|
|
987
|
0
|
|
|
|
|
|
my $stuff = { |
988
|
|
|
|
|
|
|
name => $name, |
989
|
|
|
|
|
|
|
description => $desc, |
990
|
|
|
|
|
|
|
milestone_id => $milestone_id, |
991
|
|
|
|
|
|
|
entries => $entries |
992
|
|
|
|
|
|
|
}; |
993
|
|
|
|
|
|
|
|
994
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/add_plan/$project_id",'POST',$stuff); |
995
|
0
|
|
|
|
|
|
return $result; |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
=head2 B |
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
Deletes specified plan. |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
=over 4 |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
=item INTEGER C - ID of plan to delete. |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
=back |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
Returns BOOLEAN. |
1009
|
|
|
|
|
|
|
|
1010
|
|
|
|
|
|
|
$tr->deletePlan(8675309); |
1011
|
|
|
|
|
|
|
|
1012
|
|
|
|
|
|
|
=cut |
1013
|
|
|
|
|
|
|
|
1014
|
|
|
|
|
|
|
sub deletePlan { |
1015
|
0
|
|
|
0
|
1
|
|
my ($self,$plan_id) = @_; |
1016
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/delete_plan/$plan_id",'POST'); |
1017
|
0
|
|
|
|
|
|
return $result; |
1018
|
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
=head2 B |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
Deletes specified plan. |
1023
|
|
|
|
|
|
|
|
1024
|
|
|
|
|
|
|
=over 4 |
1025
|
|
|
|
|
|
|
|
1026
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
1027
|
|
|
|
|
|
|
|
1028
|
|
|
|
|
|
|
=back |
1029
|
|
|
|
|
|
|
|
1030
|
|
|
|
|
|
|
Returns ARRAYREF of plan definition HASHREFs. |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
$tr->getPlans(8); |
1033
|
|
|
|
|
|
|
|
1034
|
|
|
|
|
|
|
=cut |
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
sub getPlans { |
1037
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id) = @_; |
1038
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_plans/$project_id"); |
1039
|
|
|
|
|
|
|
} |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
=head2 B |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
Gets specified plan by name. |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
=over 4 |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
=item STRING C - Name of test plan. |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
=back |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
Returns plan definition HASHREF. |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
$tr->getPlanByName(8,'GosPlan'); |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
=cut |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
sub getPlanByName { |
1060
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$name) = @_; |
1061
|
0
|
|
|
|
|
|
my $plans = $self->getPlans($project_id); |
1062
|
0
|
|
|
|
|
|
foreach my $plan (@$plans) { |
1063
|
0
|
0
|
|
|
|
|
return $plan if $plan->{'name'} eq $name; |
1064
|
|
|
|
|
|
|
} |
1065
|
0
|
|
|
|
|
|
return 0; |
1066
|
|
|
|
|
|
|
} |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
=head2 B |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
Gets specified plan by ID. |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
=over 4 |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
=item INTEGER C - ID of plan. |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
=back |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
Returns plan definition HASHREF. |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
$tr->getPlanByID(2); |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
=cut |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
sub getPlanByID { |
1085
|
0
|
|
|
0
|
1
|
|
my ($self,$plan_id) = @_; |
1086
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_plan/$plan_id"); |
1087
|
|
|
|
|
|
|
} |
1088
|
|
|
|
|
|
|
|
1089
|
|
|
|
|
|
|
=head1 MILESTONE METHODS |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
=head2 B |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
Create a milestone. |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
=over 4 |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
=item STRING C - Name of milestone |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
=item STRING C (optional) - Description of milestone |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
=item INTEGER C - Date at which milestone should be completed. Unix Timestamp. |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
=back |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
Returns milestone definition HASHREF, or false on failure. |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
$tr->createMilestone(1,'Patriotic victory of world perlism','Accomplish by Robo-Signed Soviet 5-year plan',time()+157788000); |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
=cut |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
sub createMilestone { |
1114
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$name,$desc,$due_on) = @_; |
1115
|
|
|
|
|
|
|
|
1116
|
0
|
|
|
|
|
|
my $stuff = { |
1117
|
|
|
|
|
|
|
name => $name, |
1118
|
|
|
|
|
|
|
description => $desc, |
1119
|
|
|
|
|
|
|
due_on => $due_on # unix timestamp |
1120
|
|
|
|
|
|
|
}; |
1121
|
|
|
|
|
|
|
|
1122
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/add_milestone/$project_id",'POST',$stuff); |
1123
|
0
|
|
|
|
|
|
return $result; |
1124
|
|
|
|
|
|
|
} |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
=head2 B |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
Deletes specified milestone. |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
=over 4 |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=item INTEGER C - ID of milestone to delete. |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
=back |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
Returns BOOLEAN. |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
$tr->deleteMilestone(86); |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
=cut |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
sub deleteMilestone { |
1143
|
0
|
|
|
0
|
1
|
|
my ($self,$milestone_id) = @_; |
1144
|
0
|
|
|
|
|
|
my $result = $self->_doRequest("index.php?/api/v2/delete_milestone/$milestone_id",'POST'); |
1145
|
0
|
|
|
|
|
|
return $result; |
1146
|
|
|
|
|
|
|
} |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
=head2 B |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
Get milestones for some project. |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
=over 4 |
1153
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
=back |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
Returns ARRAYREF of milestone definition HASHREFs. |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
$tr->getMilestones(8); |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=cut |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
sub getMilestones { |
1165
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id) = @_; |
1166
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_milestones/$project_id"); |
1167
|
|
|
|
|
|
|
} |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
=head2 B |
1170
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
Gets specified milestone by name. |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
=over 4 |
1174
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
=item INTEGER C - ID of parent project. |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
=item STRING C - Name of milestone. |
1178
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
=back |
1180
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
Returns milestone definition HASHREF. |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
$tr->getMilestoneByName(8,'whee'); |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
=cut |
1186
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
sub getMilestoneByName { |
1188
|
0
|
|
|
0
|
1
|
|
my ($self,$project_id,$name) = @_; |
1189
|
0
|
|
|
|
|
|
my $milestones = $self->getMilestones($project_id); |
1190
|
0
|
|
|
|
|
|
foreach my $milestone (@$milestones) { |
1191
|
0
|
0
|
|
|
|
|
return $milestone if $milestone->{'name'} eq $name; |
1192
|
|
|
|
|
|
|
} |
1193
|
0
|
|
|
|
|
|
return 0; |
1194
|
|
|
|
|
|
|
} |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
=head2 B |
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
Gets specified milestone by ID. |
1199
|
|
|
|
|
|
|
|
1200
|
|
|
|
|
|
|
=over 4 |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
=item INTEGER C - ID of milestone. |
1203
|
|
|
|
|
|
|
|
1204
|
|
|
|
|
|
|
=back |
1205
|
|
|
|
|
|
|
|
1206
|
|
|
|
|
|
|
Returns milestione definition HASHREF. |
1207
|
|
|
|
|
|
|
|
1208
|
|
|
|
|
|
|
$tr->getMilestoneByID(2); |
1209
|
|
|
|
|
|
|
|
1210
|
|
|
|
|
|
|
=cut |
1211
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
sub getMilestoneByID { |
1213
|
0
|
|
|
0
|
1
|
|
my ($self,$milestone_id) = @_; |
1214
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_milestone/$milestone_id"); |
1215
|
|
|
|
|
|
|
} |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
=head1 TEST METHODS |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=head2 B |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
Get tests for some run. |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=over 4 |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
=item INTEGER C - ID of parent run. |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=back |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
Returns ARRAYREF of test definition HASHREFs. |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
$tr->getTests(8); |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
=cut |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
sub getTests { |
1236
|
0
|
|
|
0
|
1
|
|
my ($self,$run_id) = @_; |
1237
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_tests/$run_id"); |
1238
|
|
|
|
|
|
|
} |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
=head2 B |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
Gets specified test by name. |
1243
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
=over 4 |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
=item INTEGER C - ID of parent run. |
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
=item STRING C - Name of milestone. |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
=back |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
Returns test definition HASHREF. |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
$tr->getTestByName(36,'wheeTest'); |
1255
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
=cut |
1257
|
|
|
|
|
|
|
|
1258
|
|
|
|
|
|
|
sub getTestByName { |
1259
|
0
|
|
|
0
|
1
|
|
my ($self,$run_id,$name) = @_; |
1260
|
0
|
|
|
|
|
|
my $tests = $self->getTests($run_id); |
1261
|
0
|
|
|
|
|
|
foreach my $test (@$tests) { |
1262
|
0
|
0
|
|
|
|
|
return $test if $test->{'title'} eq $name; |
1263
|
|
|
|
|
|
|
} |
1264
|
0
|
|
|
|
|
|
return 0; |
1265
|
|
|
|
|
|
|
} |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
=head2 B |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
Gets specified test by ID. |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
=over 4 |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
=item INTEGER C - ID of test. |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
=back |
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
Returns test definition HASHREF. |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
$tr->getTestByID(222222); |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
=cut |
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
sub getTestByID { |
1284
|
0
|
|
|
0
|
1
|
|
my ($self,$test_id) = @_; |
1285
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/get_test/$test_id"); |
1286
|
|
|
|
|
|
|
} |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
=head2 B |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
Gets custom fields that can be set for tests. |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
Returns ARRAYREF of result definition HASHREFs. |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
=cut |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
sub getTestResultFields { |
1297
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1298
|
0
|
|
|
|
|
|
return $self->_doRequest('index.php?/api/v2/get_result_fields'); |
1299
|
|
|
|
|
|
|
} |
1300
|
|
|
|
|
|
|
|
1301
|
|
|
|
|
|
|
=head2 B |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
Gets all possible statuses a test can be set to. |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
Returns ARRAYREF of status definition HASHREFs. |
1306
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
=cut |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
sub getPossibleTestStatuses { |
1310
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
1311
|
0
|
|
|
|
|
|
return $self->_doRequest('index.php?/api/v2/get_statuses'); |
1312
|
|
|
|
|
|
|
} |
1313
|
|
|
|
|
|
|
|
1314
|
|
|
|
|
|
|
=head2 B |
1315
|
|
|
|
|
|
|
|
1316
|
|
|
|
|
|
|
Creates a result entry for a test. |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
Returns result definition HASHREF. |
1319
|
|
|
|
|
|
|
|
1320
|
|
|
|
|
|
|
$options = { |
1321
|
|
|
|
|
|
|
elapsed => '30m 22s', |
1322
|
|
|
|
|
|
|
defects => ['TSR-3','BOOM-44'], |
1323
|
|
|
|
|
|
|
version => '6969' |
1324
|
|
|
|
|
|
|
}; |
1325
|
|
|
|
|
|
|
|
1326
|
|
|
|
|
|
|
$custom_options = { |
1327
|
|
|
|
|
|
|
step_results => [ |
1328
|
|
|
|
|
|
|
{ |
1329
|
|
|
|
|
|
|
content => 'Step 1', |
1330
|
|
|
|
|
|
|
expected => "Bought Groceries", |
1331
|
|
|
|
|
|
|
actual => "No Dinero!", |
1332
|
|
|
|
|
|
|
status_id => 2 |
1333
|
|
|
|
|
|
|
}, |
1334
|
|
|
|
|
|
|
{ |
1335
|
|
|
|
|
|
|
content => 'Step 2', |
1336
|
|
|
|
|
|
|
expected => 'Ate Dinner', |
1337
|
|
|
|
|
|
|
actual => 'Went Hungry', |
1338
|
|
|
|
|
|
|
status_id => 2 |
1339
|
|
|
|
|
|
|
} |
1340
|
|
|
|
|
|
|
] |
1341
|
|
|
|
|
|
|
}; |
1342
|
|
|
|
|
|
|
|
1343
|
|
|
|
|
|
|
$res = $tr->createTestResults(1,2,'Test failed because it was all like WAAAAAAA when I poked it',$options,$custom_options); |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
=cut |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
sub createTestResults { |
1348
|
0
|
|
|
0
|
1
|
|
my ($self,$test_id,$status_id,$comment,$opts,$custom_fields) = @_; |
1349
|
0
|
|
|
|
|
|
my $stuff = { |
1350
|
|
|
|
|
|
|
status_id => $status_id, |
1351
|
|
|
|
|
|
|
comment => $comment |
1352
|
|
|
|
|
|
|
}; |
1353
|
|
|
|
|
|
|
|
1354
|
|
|
|
|
|
|
#Handle options |
1355
|
0
|
0
|
0
|
|
|
|
if (defined($opts) && reftype($opts) eq 'HASH') { |
1356
|
0
|
0
|
|
|
|
|
$stuff->{'version'} = defined($opts->{'version'}) ? $opts->{'version'} : undef; |
1357
|
0
|
0
|
|
|
|
|
$stuff->{'elapsed'} = defined($opts->{'elapsed'}) ? $opts->{'elapsed'} : undef; |
1358
|
0
|
0
|
|
|
|
|
$stuff->{'defects'} = defined($opts->{'defects'}) ? join(',',@{$opts->{'defects'}}) : undef; |
|
0
|
|
|
|
|
|
|
1359
|
0
|
0
|
|
|
|
|
$stuff->{'assignedto_id'} = defined($opts->{'assignedto_id'}) ? $opts->{'assignedto_id'} : undef; |
1360
|
|
|
|
|
|
|
} |
1361
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
#Handle custom fields |
1363
|
0
|
0
|
0
|
|
|
|
if (defined($custom_fields) && reftype($custom_fields) eq 'HASH') { |
1364
|
0
|
|
|
|
|
|
foreach my $field (keys(%$custom_fields)) { |
1365
|
0
|
|
|
|
|
|
$stuff->{"custom_$field"} = $custom_fields->{$field}; |
1366
|
|
|
|
|
|
|
} |
1367
|
|
|
|
|
|
|
} |
1368
|
|
|
|
|
|
|
|
1369
|
0
|
|
|
|
|
|
return $self->_doRequest("index.php?/api/v2/add_result/$test_id",'POST',$stuff); |
1370
|
|
|
|
|
|
|
} |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
=head2 B |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
Get the recorded results for desired test, limiting output to 'limit' entries. |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
=over 4 |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
=item INTEGER C - ID of desired test |
1379
|
|
|
|
|
|
|
|
1380
|
|
|
|
|
|
|
=item POSITIVE INTEGER C - provide no more than this number of results. |
1381
|
|
|
|
|
|
|
|
1382
|
|
|
|
|
|
|
=back |
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
Returns ARRAYREF of result definition HASHREFs. |
1385
|
|
|
|
|
|
|
|
1386
|
|
|
|
|
|
|
=cut |
1387
|
|
|
|
|
|
|
|
1388
|
|
|
|
|
|
|
sub getTestResults { |
1389
|
0
|
|
|
0
|
1
|
|
my ($self,$test_id,$limit) = @_; |
1390
|
0
|
|
|
|
|
|
my $url = "index.php?/api/v2/get_results/$test_id"; |
1391
|
0
|
0
|
|
|
|
|
$url .= "&limit=$limit" if defined($limit); |
1392
|
0
|
|
|
|
|
|
return $self->_doRequest($url); |
1393
|
|
|
|
|
|
|
} |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
=head2 B |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
Convenience method to build the stepResult hashes seen in the custom options for getTestResults. |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
=cut |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
#Convenience method for building stepResults |
1402
|
|
|
|
|
|
|
sub buildStepResults { |
1403
|
0
|
|
|
0
|
1
|
|
my ($content,$expected,$actual,$status_id) = @_; |
1404
|
|
|
|
|
|
|
return { |
1405
|
0
|
|
|
|
|
|
content => $content, |
1406
|
|
|
|
|
|
|
expected => $expected, |
1407
|
|
|
|
|
|
|
actual => $actual, |
1408
|
|
|
|
|
|
|
status_id => $status_id |
1409
|
|
|
|
|
|
|
}; |
1410
|
|
|
|
|
|
|
} |
1411
|
|
|
|
|
|
|
|
1412
|
|
|
|
|
|
|
1; |
1413
|
|
|
|
|
|
|
|
1414
|
|
|
|
|
|
|
__END__ |