| 1 | # ABSTRACT: Provides an interface to TestRail's REST api via HTTP | ||||||||||||||||||||||||||||||||
| 2 | # PODNAME: TestRail::API | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | package TestRail::API; | ||||||||||||||||||||||||||||||||
| 5 | 36 | $TestRail::API::VERSION = '0.052'; | |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 36 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 36 | ▶ | use Carp qw{cluck confess}; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 36 | ▶ | use Scalar::Util qw{reftype looks_like_number}; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 36 | ▶ | use Clone 'clone'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 36 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | use Types::Standard | ||||||||||||||||||||||||||||||||
| 18 | 36 | ▶ | qw( slurpy ClassName Object Str Int Bool HashRef ArrayRef Maybe Optional); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 36 | ▶ | use Type::Params qw( compile ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 36 | ▶ | use JSON::MaybeXS 1.001000 (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 36 | ▶ | use HTTP::Request; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 36 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 36 | ▶ | use HTTP::CookieJar::LWP; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 36 | ▶ | use Data::Validate::URI qw{is_uri}; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 36 | ▶ | use List::Util 1.33; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | 36 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 106 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=19 SCAR=36.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 106 | state $check = compile( | |||||||||||||||||||||||||||||||
| 31 | ClassName, | ||||||||||||||||||||||||||||||||
| 32 | Str, | ||||||||||||||||||||||||||||||||
| 33 | Str, | ||||||||||||||||||||||||||||||||
| 34 | Str, | ||||||||||||||||||||||||||||||||
| 35 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 36 | Optional [ Maybe [Bool] ], | ||||||||||||||||||||||||||||||||
| 37 | Optional [ Maybe [Bool] ], | ||||||||||||||||||||||||||||||||
| 38 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 39 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||
| 41 | my ( | ||||||||||||||||||||||||||||||||
| 42 | 106 | $class, $apiurl, $user, | |||||||||||||||||||||||||||||||
| 43 | $pass, $encoding, $debug, | ||||||||||||||||||||||||||||||||
| 44 | $do_post_redirect, $max_tries, $userfetch_opts | ||||||||||||||||||||||||||||||||
| 45 | ) = $check->(@_); | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 106 | ▶ | die("Invalid URI passed to constructor") if !is_uri($apiurl); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 105 | ▶ | $debug //= 0; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$debug //= 0
MC/DC0%0/1
$debug //= 0
$debug
Truth table50%1/2
A
A= $debug
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | my $self = { | ||||||||||||||||||||||||||||||||
| 51 | user => $user, | ||||||||||||||||||||||||||||||||
| 52 | pass => $pass, | ||||||||||||||||||||||||||||||||
| 53 | apiurl => $apiurl, | ||||||||||||||||||||||||||||||||
| 54 | debug => $debug, | ||||||||||||||||||||||||||||||||
| 55 | encoding => $encoding || 'UTF-8', | ||||||||||||||||||||||||||||||||
| 56 | testtree => [], | ||||||||||||||||||||||||||||||||
| 57 | flattree => [], | ||||||||||||||||||||||||||||||||
| 58 | user_cache => [], | ||||||||||||||||||||||||||||||||
| 59 | configurations => {}, | ||||||||||||||||||||||||||||||||
| 60 | tr_fields => undef, | ||||||||||||||||||||||||||||||||
| 61 | 105 | ▶ | tr_project_id => $userfetch_opts->{'project_id'}, | ||||||||||||||||||||||||||||||
|
Condition75%3/4
$encoding || 'UTF-8'
$max_tries // 1
MC/DC0%0/1
$encoding || 'UTF-8'
$encoding
MC/DC100%1/1
$max_tries // 1
$max_tries
Truth table50%1/2
A
A= $encoding
Truth table100%2/2
A
A= $max_tries
| |||||||||||||||||||||||||||||||||
| 62 | default_request => undef, | ||||||||||||||||||||||||||||||||
| 63 | global_limit => 250, #Discovered by experimentation | ||||||||||||||||||||||||||||||||
| 64 | browser => LWP::UserAgent->new( | ||||||||||||||||||||||||||||||||
| 65 | keep_alive => 10, | ||||||||||||||||||||||||||||||||
| 66 | cookie_jar => HTTP::CookieJar::LWP->new(), | ||||||||||||||||||||||||||||||||
| 67 | ), | ||||||||||||||||||||||||||||||||
| 68 | do_post_redirect => $do_post_redirect, | ||||||||||||||||||||||||||||||||
| 69 | max_tries => $max_tries // 1, | ||||||||||||||||||||||||||||||||
| 70 | retry_delay => 5, | ||||||||||||||||||||||||||||||||
| 71 | }; | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | #Allow POST redirects | ||||||||||||||||||||||||||||||||
| 74 | 105 | ▶ | if ( $self->{do_post_redirect} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | 56 | push @{ $self->{'browser'}->requests_redirectable }, 'POST'; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | #Check chara encoding | ||||||||||||||||||||||||||||||||
| 79 | $self->{'encoding-nonaliased'} = | ||||||||||||||||||||||||||||||||
| 80 | 105 | Encode::resolve_alias( $self->{'encoding'} ); | |||||||||||||||||||||||||||||||
| 81 | die( "Invalid encoding alias '" | ||||||||||||||||||||||||||||||||
| 82 | . $self->{'encoding'} | ||||||||||||||||||||||||||||||||
| 83 | . "' passed, see Encoding::Supported for a list of allowed encodings" | ||||||||||||||||||||||||||||||||
| 84 | 105 | ▶ | ) unless $self->{'encoding-nonaliased'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | die( "Invalid encoding '" | ||||||||||||||||||||||||||||||||
| 87 | . $self->{'encoding-nonaliased'} | ||||||||||||||||||||||||||||||||
| 88 | . "' passed, see Encoding::Supported for a list of allowed encodings" | ||||||||||||||||||||||||||||||||
| 89 | ) | ||||||||||||||||||||||||||||||||
| 90 | 105 | ▶ | unless grep { $_ eq $self->{'encoding-nonaliased'} } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | ( Encode->encodings(":all") ); | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | #Create default request to pass on to LWP::UserAgent | ||||||||||||||||||||||||||||||||
| 94 | 105 | $self->{'default_request'} = HTTP::Request->new(); | |||||||||||||||||||||||||||||||
| 95 | 105 | $self->{'default_request'}->authorization_basic( $user, $pass ); | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 105 | bless( $self, $class ); | |||||||||||||||||||||||||||||||
| 98 | 105 | ▶ | return $self if $self->debug; #For easy class testing without mocks | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | # Manually do the get_users call to check HTTP status... | ||||||||||||||||||||||||||||||||
| 101 | # Allow users to skip the check if you have a zillion users etc, | ||||||||||||||||||||||||||||||||
| 102 | # as apparently that is fairly taxing on TR itself. | ||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | if ( !$userfetch_opts->{skip_usercache} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 1 | my $res = $self->getUsers( $userfetch_opts->{project_id} ); | |||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | confess "Error: network unreachable" if !defined($res); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | if ( ( reftype($res) || 'undef' ) ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($res) || 'undef'
MC/DC0%0/1
builtin::reftype($res) || 'undef'
builtin::reftype($res)
Truth table50%1/2
A
A= builtin::reftype($res)
| |||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | confess "Unexpected return from _doRequest: $res" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 108 | if !looks_like_number($res); | ||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | confess | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | "Could not communicate with TestRail Server! Check that your URI is correct, and your TestRail installation is functioning correctly." | ||||||||||||||||||||||||||||||||
| 111 | if $res == -500; | ||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | confess | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | "Could not list testRail users! Check that your TestRail installation has it's API enabled, and your credentials are correct" | ||||||||||||||||||||||||||||||||
| 114 | if $res == -403; | ||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | confess "Bad user credentials!" if $res == -401; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | confess | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | "HTTP error $res encountered while communicating with TestRail server. Resolve issue and try again." | ||||||||||||||||||||||||||||||||
| 118 | if $res < 0; | ||||||||||||||||||||||||||||||||
| 119 | 0 | confess "Unknown error occurred: $res"; | |||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | confess | ||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | "No users detected on TestRail Install! Check that your API is functioning correctly." | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | if !scalar(@$res); | ||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 1838 | ▶ | sub apiurl { | ||||||||||||||||||||||||||||||
|
Subroutine
apiurl: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 130 | 1838 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 131 | 1838 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 132 | 1838 | return $self->{'apiurl'}; | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 1832 | ▶ | sub debug { | ||||||||||||||||||||||||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 136 | 1832 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 137 | 1832 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 138 | 1832 | return $self->{'debug'}; | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | #Convenient JSON-HTTP fetcher | ||||||||||||||||||||||||||||||||
| 142 | 1726 | ▶ | sub _doRequest { | ||||||||||||||||||||||||||||||
|
Subroutine
_doRequest: called CC=13 SCAR=28.7
| |||||||||||||||||||||||||||||||||
| 143 | 1726 | state $check = compile( | |||||||||||||||||||||||||||||||
| 144 | Object, Str, | ||||||||||||||||||||||||||||||||
| 145 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 146 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||
| 148 | 1726 | my ( $self, $path, $method, $data ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | 1726 | $self->{num_tries}++; | |||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 1726 | my $req = clone $self->{'default_request'}; | |||||||||||||||||||||||||||||||
| 153 | 1726 | ▶ | $method //= 'GET'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$method //= "GET"
MC/DC100%1/1
$method //= "GET"
$method
Truth table100%2/2
A
A= $method
| |||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | 1726 | $req->method($method); | |||||||||||||||||||||||||||||||
| 156 | 1726 | $req->url( $self->apiurl . '/' . $path ); | |||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 1726 | ▶ | warn "$method " . $self->apiurl . "/$path" if $self->debug; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | 1726 | my $coder = JSON::MaybeXS->new; | |||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | #Data sent is JSON, and encoded per user preference | ||||||||||||||||||||||||||||||||
| 163 | my $content = | ||||||||||||||||||||||||||||||||
| 164 | $data | ||||||||||||||||||||||||||||||||
| 165 | 1726 | ▶ | ? Encode::encode( $self->{'encoding-nonaliased'}, $coder->encode($data) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 166 | : ''; | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 1726 | $req->content($content); | |||||||||||||||||||||||||||||||
| 169 | $req->header( | ||||||||||||||||||||||||||||||||
| 170 | 1726 | "Content-Type" => "application/json; charset=" . $self->{'encoding'} ); | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 1726 | my $response = eval { $self->{'browser'}->request($req) }; | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | #Uncomment to generate mocks | ||||||||||||||||||||||||||||||||
| 175 | #use Data::Dumper; | ||||||||||||||||||||||||||||||||
| 176 | #open(my $fh, '>>', 'mock.out'); | ||||||||||||||||||||||||||||||||
| 177 | #print $fh "{\n\n"; | ||||||||||||||||||||||||||||||||
| 178 | #print $fh Dumper($path,'200','OK',$response->headers,$response->content); | ||||||||||||||||||||||||||||||||
| 179 | #print $fh '$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));'; | ||||||||||||||||||||||||||||||||
| 180 | #print $fh "\n\n}\n\n"; | ||||||||||||||||||||||||||||||||
| 181 | #close $fh; | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 1726 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | #LWP threw an ex, probably a timeout | ||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ( $self->{num_tries} >= $self->{max_tries} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 187 | 0 | $self->{num_tries} = 0; | |||||||||||||||||||||||||||||||
| 188 | 0 | confess "Failed to satisfy request after $self->{num_tries} tries!"; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | cluck | ||||||||||||||||||||||||||||||||
| 191 | 0 | "WARNING: TestRail API request failed due to timeout, or other LWP fatal condition, re-trying request...\n"; | |||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sleep $self->{retry_delay} if $self->{retry_delay}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 193 | 0 | goto &_doRequest; | |||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 1726 | ▶ | return $response if !defined($response); #worst case | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 1726 | ▶ | if ( $response->code == 403 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | 1 | confess "ERROR 403: Access Denied: " . $response->content; | |||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | 1725 | ▶ | if ( $response->code == 401 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 202 | 1 | confess "ERROR 401: Authentication failed: " . $response->content; | |||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | 1724 | ▶ | if ( $response->code != 200 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | #LWP threw an ex, probably a timeout | ||||||||||||||||||||||||||||||||
| 208 | 121 | ▶ | if ( $self->{num_tries} >= $self->{max_tries} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | 119 | $self->{num_tries} = 0; | |||||||||||||||||||||||||||||||
| 210 | 119 | cluck "ERROR: Arguments Bad? (got code " | |||||||||||||||||||||||||||||||
| 211 | . $response->code . "): " | ||||||||||||||||||||||||||||||||
| 212 | . $response->content; | ||||||||||||||||||||||||||||||||
| 213 | 119 | return -int( $response->code ); | |||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||
| 215 | 2 | cluck "WARNING: TestRail API request failed (got code " | |||||||||||||||||||||||||||||||
| 216 | . $response->code | ||||||||||||||||||||||||||||||||
| 217 | . "), re-trying request...\n"; | ||||||||||||||||||||||||||||||||
| 218 | 2 | ▶ | sleep $self->{retry_delay} if $self->{retry_delay}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | 2 | goto &_doRequest; | |||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||
| 222 | 1603 | $self->{num_tries} = 0; | |||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | 1603 | ▶ | try { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 225 | 1603 | return $coder->decode( $response->content ); | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | 9 | ▶ | catch { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=23.3
| |||||||||||||||||||||||||||||||||
| 228 | 9 | ▶ | if ( $response->code == 200 && !$response->content ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$response->code == 200 and not $response->content
MC/DC0%0/2
$response->code == 200 and not $response->content
$response->code == 200
not $response->content
Truth table33%1/3
A and not(B)
A= $response->code == 200B= not $response->content
| |||||||||||||||||||||||||||||||||
| 229 | 9 | return 1; #This function probably just returns no data | |||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | else { | ||||||||||||||||||||||||||||||||
| 232 | 0 | cluck "ERROR: Malformed JSON returned by API."; | |||||||||||||||||||||||||||||||
| 233 | 0 | cluck $@; | |||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ( !$self->debug ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | { #Otherwise we've already printed this, but we need to know if we encounter this | ||||||||||||||||||||||||||||||||
| 236 | 0 | cluck "RAW CONTENT:"; | |||||||||||||||||||||||||||||||
| 237 | 0 | cluck $response->content; | |||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||
| 242 | 1603 | } | |||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | 78 | ▶ | sub getUsers { | ||||||||||||||||||||||||||||||
|
Subroutine
getUsers: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 245 | 78 | state $check = compile( Object, Optional [ Maybe [Str] ] ); | |||||||||||||||||||||||||||||||
| 246 | 78 | my ( $self, $project_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | # Return shallow clone of user_cache if set. | ||||||||||||||||||||||||||||||||
| 249 | 6 | return [ @{ $self->{'user_cache'} } ] | |||||||||||||||||||||||||||||||
| 250 | if ref $self->{'user_cache'} eq 'ARRAY' | ||||||||||||||||||||||||||||||||
| 251 | 78 | ▶ | && scalar( @{ $self->{'user_cache'} } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
ref $self->{"user_cache"} eq "ARRAY" and scalar @{$self->{"user_cache"};}
MC/DC0%0/1
ref $self->{"user_cache"} eq "ARRAY" and scalar @{$self->{"user_cache"};}
ref $self->{"user_cache"} eq "ARRAY"
Truth table50%1/2
A
A= ref $self->{"user_cache"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 252 | 72 | ▶ | my $maybe_project = $project_id ? "/$project_id" : ''; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | 72 | my $res = $self->_doRequest("index.php?/api/v2/get_users$maybe_project"); | |||||||||||||||||||||||||||||||
| 254 | 70 | ▶ | return -500 if !$res || ( reftype($res) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $res or (builtin::reftype($res) || "undef") ne "ARRAY"
builtin::reftype($res) || 'undef'
MC/DC50%1/2
not $res or (builtin::reftype($res) || "undef") ne "ARRAY"
not $res
builtin::reftype($res)
Truth table66%2/3
not(A) or B
A= not $resB= builtin::reftype($res)
| |||||||||||||||||||||||||||||||||
| 255 | 60 | $self->{'user_cache'} = $res; | |||||||||||||||||||||||||||||||
| 256 | 60 | return clone($res); | |||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | 4 | ▶ | sub getUserByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getUserByID: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 260 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 261 | 4 | my ( $self, $user ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 3 | my $users = $self->getUsers(); | |||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | return $users if ref $users ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 265 | 1 | foreach my $usr (@$users) { | |||||||||||||||||||||||||||||||
| 266 | 1 | ▶ | return $usr if $usr->{'id'} == $user; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 4 | ▶ | sub getUserByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getUserByName: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 272 | 4 | state $check = compile( Object, Str ); | |||||||||||||||||||||||||||||||
| 273 | 4 | my ( $self, $user ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 3 | my $users = $self->getUsers(); | |||||||||||||||||||||||||||||||
| 276 | 3 | ▶ | return $users if ref $users ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 277 | 1 | foreach my $usr (@$users) { | |||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | return $usr if $usr->{'name'} eq $user; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | sub getUserByEmail { | ||||||||||||||||||||||||||||||
|
Subroutine
getUserByEmail: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 284 | 4 | state $check = compile( Object, Str ); | |||||||||||||||||||||||||||||||
| 285 | 4 | my ( $self, $email ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 3 | my $users = $self->getUsers(); | |||||||||||||||||||||||||||||||
| 288 | 3 | ▶ | return $users if ref $users ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 289 | 1 | foreach my $usr (@$users) { | |||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | return $usr if $usr->{'email'} eq $email; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||
| 292 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 7 | ▶ | sub userNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
userNamesToIds: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 296 | 7 | state $check = compile( Object, slurpy ArrayRef [Str] ); | |||||||||||||||||||||||||||||||
| 297 | 7 | my ( $self, $names ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 7 | ▶ | confess("At least one user name must be provided") if !scalar(@$names); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | 12 | my @ret = grep { defined $_ } map { | |||||||||||||||||||||||||||||||
| 301 | 12 | my $user = $_; | |||||||||||||||||||||||||||||||
| 302 | 12 | my @list = grep { $user->{'name'} eq $_ } @$names; | |||||||||||||||||||||||||||||||
| 303 | 12 | ▶ | scalar(@list) ? $user->{'id'} : undef | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 6 | } @{ $self->getUsers() }; | |||||||||||||||||||||||||||||||
| 305 | 6 | ▶ | confess("One or more user names provided does not exist in TestRail.") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 306 | unless scalar(@$names) == scalar(@ret); | ||||||||||||||||||||||||||||||||
| 307 | 5 | return @ret; | |||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | 4 | ▶ | sub createProject { | ||||||||||||||||||||||||||||||
|
Subroutine
createProject: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 311 | 4 | state $check = compile( | |||||||||||||||||||||||||||||||
| 312 | Object, Str, | ||||||||||||||||||||||||||||||||
| 313 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 314 | Optional [ Maybe [Bool] ] | ||||||||||||||||||||||||||||||||
| 315 | ); | ||||||||||||||||||||||||||||||||
| 316 | 4 | my ( $self, $name, $desc, $announce ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | 3 | ▶ | $desc //= 'res ipsa loquiter'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$desc //= "res ipsa loquiter"
MC/DC100%1/1
$desc //= "res ipsa loquiter"
$desc
Truth table100%2/2
A
A= $desc
| |||||||||||||||||||||||||||||||||
| 319 | 3 | ▶ | $announce //= 0; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$announce //= 0
MC/DC0%0/1
$announce //= 0
$announce
Truth table50%1/2
A
A= $announce
| |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | 3 | my $input = { | |||||||||||||||||||||||||||||||
| 322 | name => $name, | ||||||||||||||||||||||||||||||||
| 323 | announcement => $desc, | ||||||||||||||||||||||||||||||||
| 324 | show_announcement => $announce | ||||||||||||||||||||||||||||||||
| 325 | }; | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 3 | return $self->_doRequest( 'index.php?/api/v2/add_project', 'POST', $input ); | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 4 | ▶ | sub deleteProject { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteProject: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 331 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 332 | 4 | my ( $self, $proj ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 3 | return $self->_doRequest( 'index.php?/api/v2/delete_project/' . $proj, | |||||||||||||||||||||||||||||||
| 335 | 'POST' ); | ||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | 106 | ▶ | sub getProjects { | ||||||||||||||||||||||||||||||
|
Subroutine
getProjects: called CC=8 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 339 | 106 | state $check = compile( Object, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 340 | 106 | my ( $self, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | 106 | my $result = $self->_doRequest( 'index.php?/api/v2/get_projects' | |||||||||||||||||||||||||||||||
| 343 | . _convert_filters_to_string($filters) ); | ||||||||||||||||||||||||||||||||
| 344 | 106 | ▶ | return -500 if !$result || ( reftype($result) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $result or (builtin::reftype($result) || "undef") ne "HASH"
builtin::reftype($result) || 'undef'
MC/DC50%1/2
not $result or (builtin::reftype($result) || "undef") ne "HASH"
not $result
builtin::reftype($result)
Truth table66%2/3
not(A) or B
A= not $resultB= builtin::reftype($result)
| |||||||||||||||||||||||||||||||||
| 345 | 100 | my $projects = $result->{'projects'}; | |||||||||||||||||||||||||||||||
| 346 | 100 | ▶ | return -500 if !$projects || ( reftype($projects) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
builtin::reftype($projects) || 'undef'
MC/DC0%0/2
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
not $projects
builtin::reftype($projects)
Truth table33%1/3
not(A) or B
A= not $projectsB= builtin::reftype($projects)
| |||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||
| 348 | #Save state for future use, if needed | ||||||||||||||||||||||||||||||||
| 349 | 100 | $self->{'testtree'} = $projects; | |||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | 100 | foreach my $pj ( @{$projects} ) { | |||||||||||||||||||||||||||||||
| 352 | 300 | $pj->{'type'} = 'project'; | |||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | 100 | return $projects; | |||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||
| 358 | 121 | ▶ | sub getProjectByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getProjectByName: called CC=10 SCAR=23.6
Pod
documented
| |||||||||||||||||||||||||||||||||
| 359 | 121 | state $check = compile( Object, Str ); | |||||||||||||||||||||||||||||||
| 360 | 121 | my ( $self, $project ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||
| 362 | #See if we already have the project list... | ||||||||||||||||||||||||||||||||
| 363 | 120 | my $projects = $self->{'testtree'}; | |||||||||||||||||||||||||||||||
| 364 | 120 | ▶ | return -500 if !$projects || ( reftype($projects) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
builtin::reftype($projects) || 'undef'
MC/DC0%0/2
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
not $projects
builtin::reftype($projects)
Truth table33%1/3
not(A) or B
A= not $projectsB= builtin::reftype($projects)
| |||||||||||||||||||||||||||||||||
| 365 | 120 | ▶ | $projects = $self->getProjects() unless scalar(@$projects); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | #Search project list for project | ||||||||||||||||||||||||||||||||
| 368 | 120 | ▶ | return -500 if !$projects || ( reftype($projects) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
builtin::reftype($projects) || 'undef'
MC/DC50%1/2
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
not $projects
builtin::reftype($projects)
Truth table66%2/3
not(A) or B
A= not $projectsB= builtin::reftype($projects)
| |||||||||||||||||||||||||||||||||
| 369 | 118 | for my $candidate (@$projects) { | |||||||||||||||||||||||||||||||
| 370 | 232 | ▶ | return $candidate if ( $candidate->{'name'} eq $project ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | 1 | return 0; | |||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||
| 376 | 8 | ▶ | sub getProjectByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getProjectByID: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 377 | 8 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 378 | 8 | my ( $self, $project ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | #See if we already have the project list... | ||||||||||||||||||||||||||||||||
| 381 | 7 | my $projects = $self->{'testtree'}; | |||||||||||||||||||||||||||||||
| 382 | 7 | ▶ | $projects = $self->getProjects() unless scalar(@$projects); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||
| 384 | #Search project list for project | ||||||||||||||||||||||||||||||||
| 385 | 7 | ▶ | return -500 if !$projects || ( reftype($projects) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
builtin::reftype($projects) || 'undef'
MC/DC50%1/2
not $projects or (builtin::reftype($projects) || "undef") ne "ARRAY"
not $projects
builtin::reftype($projects)
Truth table66%2/3
not(A) or B
A= not $projectsB= builtin::reftype($projects)
| |||||||||||||||||||||||||||||||||
| 386 | 5 | for my $candidate (@$projects) { | |||||||||||||||||||||||||||||||
| 387 | 7 | ▶ | return $candidate if ( $candidate->{'id'} eq $project ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||
| 390 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | 5 | ▶ | sub createTestSuite { | ||||||||||||||||||||||||||||||
|
Subroutine
createTestSuite: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 394 | 5 | state $check = compile( Object, Int, Str, Optional [ Maybe [Str] ] ); | |||||||||||||||||||||||||||||||
| 395 | 5 | my ( $self, $project_id, $name, $details ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | 3 | ▶ | $details //= 'res ipsa loquiter'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$details //= "res ipsa loquiter"
MC/DC100%1/1
$details //= "res ipsa loquiter"
$details
Truth table100%2/2
A
A= $details
| |||||||||||||||||||||||||||||||||
| 398 | 3 | my $input = { | |||||||||||||||||||||||||||||||
| 399 | name => $name, | ||||||||||||||||||||||||||||||||
| 400 | description => $details | ||||||||||||||||||||||||||||||||
| 401 | }; | ||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||
| 403 | 3 | return $self->_doRequest( 'index.php?/api/v2/add_suite/' . $project_id, | |||||||||||||||||||||||||||||||
| 404 | 'POST', $input ); | ||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | 4 | ▶ | sub deleteTestSuite { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteTestSuite: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 408 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 409 | 4 | my ( $self, $suite_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | 3 | return $self->_doRequest( 'index.php?/api/v2/delete_suite/' . $suite_id, | |||||||||||||||||||||||||||||||
| 412 | 'POST' ); | ||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | 15 | ▶ | sub getTestSuites { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestSuites: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 416 | 15 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 417 | 15 | my ( $self, $proj ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||
| 419 | 14 | return $self->_doRequest( 'index.php?/api/v2/get_suites/' . $proj ); | |||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||
| 422 | 13 | ▶ | sub getTestSuiteByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestSuiteByName: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 423 | 13 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 424 | 13 | my ( $self, $project_id, $testsuite_name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||
| 426 | #TODO cache | ||||||||||||||||||||||||||||||||
| 427 | 11 | my $suites = $self->getTestSuites($project_id); | |||||||||||||||||||||||||||||||
| 428 | 11 | ▶ | return -500 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $suites or (builtin::reftype($suites) || "undef") ne "ARRAY"
builtin::reftype($suites) || 'undef'
MC/DC50%1/2
not $suites or (builtin::reftype($suites) || "undef") ne "ARRAY"
not $suites
builtin::reftype($suites)
Truth table66%2/3
not(A) or B
A= not $suitesB= builtin::reftype($suites)
| |||||||||||||||||||||||||||||||||
| 429 | if !$suites | ||||||||||||||||||||||||||||||||
| 430 | || ( reftype($suites) || 'undef' ) ne | ||||||||||||||||||||||||||||||||
| 431 | 'ARRAY'; #No suites for project, or no project | ||||||||||||||||||||||||||||||||
| 432 | 9 | foreach my $suite (@$suites) { | |||||||||||||||||||||||||||||||
| 433 | 9 | ▶ | return $suite if $suite->{'name'} eq $testsuite_name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||
| 435 | 0 | return 0; #Couldn't find it | |||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | 4 | ▶ | sub getTestSuiteByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestSuiteByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 439 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 440 | 4 | my ( $self, $testsuite_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||
| 442 | 3 | return $self->_doRequest( 'index.php?/api/v2/get_suite/' . $testsuite_id ); | |||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | 6 | ▶ | sub createSection { | ||||||||||||||||||||||||||||||
|
Subroutine
createSection: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 446 | 6 | state $check = compile( Object, Int, Int, Str, Optional [ Maybe [Int] ] ); | |||||||||||||||||||||||||||||||
| 447 | 6 | my ( $self, $project_id, $suite_id, $name, $parent_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||
| 449 | 3 | my $input = { | |||||||||||||||||||||||||||||||
| 450 | name => $name, | ||||||||||||||||||||||||||||||||
| 451 | suite_id => $suite_id | ||||||||||||||||||||||||||||||||
| 452 | }; | ||||||||||||||||||||||||||||||||
| 453 | 3 | ▶ | $input->{'parent_id'} = $parent_id if $parent_id; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||
| 455 | 3 | return $self->_doRequest( 'index.php?/api/v2/add_section/' . $project_id, | |||||||||||||||||||||||||||||||
| 456 | 'POST', $input ); | ||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||
| 459 | 4 | ▶ | sub deleteSection { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteSection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 460 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 461 | 4 | my ( $self, $section_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | 3 | return $self->_doRequest( 'index.php?/api/v2/delete_section/' . $section_id, | |||||||||||||||||||||||||||||||
| 464 | 'POST' ); | ||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | 34 | ▶ | sub getSections { | ||||||||||||||||||||||||||||||
|
Subroutine
getSections: called CC=8 SCAR=21.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 468 | 34 | state $check = compile( Object, Int, Int ); | |||||||||||||||||||||||||||||||
| 469 | 34 | my ( $self, $project_id, $suite_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | #Cache sections to reduce requests in tight loops | ||||||||||||||||||||||||||||||||
| 472 | 30 | ▶ | return $self->{'sections'}->{$suite_id} if $self->{'sections'}->{$suite_id}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 473 | 17 | my $response = $self->_doRequest( | |||||||||||||||||||||||||||||||
| 474 | "index.php?/api/v2/get_sections/$project_id&suite_id=$suite_id"); | ||||||||||||||||||||||||||||||||
| 475 | 17 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 476 | 11 | my $sections = $response->{'sections'}; | |||||||||||||||||||||||||||||||
| 477 | 11 | ▶ | return -500 if !$sections || ( reftype($sections) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $sections or (builtin::reftype($sections) || "undef") ne "ARRAY"
builtin::reftype($sections) || 'undef'
MC/DC0%0/2
not $sections or (builtin::reftype($sections) || "undef") ne "ARRAY"
not $sections
builtin::reftype($sections)
Truth table33%1/3
not(A) or B
A= not $sectionsB= builtin::reftype($sections)
| |||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||
| 479 | 11 | $self->{'sections'}->{$suite_id} = $sections; | |||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||
| 481 | 11 | return $self->{'sections'}->{$suite_id}; | |||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||
| 484 | 4 | ▶ | sub getSectionByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getSectionByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 485 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 486 | 4 | my ( $self, $section_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||
| 488 | 3 | return $self->_doRequest("index.php?/api/v2/get_section/$section_id"); | |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||
| 491 | 7 | ▶ | sub getSectionByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getSectionByName: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 492 | 7 | state $check = compile( Object, Int, Int, Str ); | |||||||||||||||||||||||||||||||
| 493 | 7 | my ( $self, $project_id, $suite_id, $section_name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||
| 495 | 4 | my $sections = $self->getSections( $project_id, $suite_id ); | |||||||||||||||||||||||||||||||
| 496 | 4 | ▶ | return -500 if !$sections || ( reftype($sections) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $sections or (builtin::reftype($sections) || "undef") ne "ARRAY"
builtin::reftype($sections) || 'undef'
MC/DC50%1/2
not $sections or (builtin::reftype($sections) || "undef") ne "ARRAY"
not $sections
builtin::reftype($sections)
Truth table66%2/3
not(A) or B
A= not $sectionsB= builtin::reftype($sections)
| |||||||||||||||||||||||||||||||||
| 497 | 2 | foreach my $sec (@$sections) { | |||||||||||||||||||||||||||||||
| 498 | 6 | ▶ | return $sec if $sec->{'name'} eq $section_name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||
| 500 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||
| 503 | 11 | ▶ | sub getChildSections { | ||||||||||||||||||||||||||||||
|
Subroutine
getChildSections: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 504 | 11 | state $check = compile( Object, Int, HashRef ); | |||||||||||||||||||||||||||||||
| 505 | 11 | my ( $self, $project_id, $section ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||
| 507 | 11 | my $sections_orig = $self->getSections( $project_id, $section->{suite_id} ); | |||||||||||||||||||||||||||||||
| 508 | 11 | ▶ | return [] | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $sections_orig or (builtin::reftype($sections_orig) || "undef") ne "ARRAY"
builtin::reftype($sections_orig) || 'undef'
MC/DC50%1/2
not $sections_orig or (builtin::reftype($sections_orig) || "undef") ne "ARRAY"
not $sections_orig
builtin::reftype($sections_orig)
Truth table66%2/3
not(A) or B
A= not $sections_origB= builtin::reftype($sections_orig)
| |||||||||||||||||||||||||||||||||
| 509 | if !$sections_orig || ( reftype($sections_orig) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 510 | my @sections = | ||||||||||||||||||||||||||||||||
| 511 | 10 | ▶ | grep { $_->{'parent_id'} ? $_->{'parent_id'} == $section->{'id'} : 0 } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 512 | @$sections_orig; | ||||||||||||||||||||||||||||||||
| 513 | 10 | foreach my $sec (@sections) { | |||||||||||||||||||||||||||||||
| 514 | push( @sections, | ||||||||||||||||||||||||||||||||
| 515 | 9 | ▶ | grep { $_->{'parent_id'} ? $_->{'parent_id'} == $sec->{'id'} : 0 } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 516 | @$sections_orig ); | ||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||
| 518 | 10 | return \@sections; | |||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | 14 | ▶ | sub sectionNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
sectionNamesToIds: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 522 | 14 | my ( $self, $project_id, $suite_id, @names ) = @_; | |||||||||||||||||||||||||||||||
| 523 | 14 | ▶ | my $sections = $self->getSections( $project_id, $suite_id ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 524 | or confess("Could not find sections in provided project/suite."); | ||||||||||||||||||||||||||||||||
| 525 | 12 | return _X_in_my_Y( $self, $sections, 'id', @names ); | |||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||
| 528 | 16 | ▶ | sub getCaseTypes { | ||||||||||||||||||||||||||||||
|
Subroutine
getCaseTypes: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 529 | 16 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 530 | 16 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 531 | 16 | ▶ | return clone( $self->{'type_cache'} ) if defined( $self->{'type_cache'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||
| 533 | 7 | my $types = $self->_doRequest("index.php?/api/v2/get_case_types"); | |||||||||||||||||||||||||||||||
| 534 | 7 | ▶ | return -500 if !$types || ( reftype($types) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $types or (builtin::reftype($types) || "undef") ne "ARRAY"
builtin::reftype($types) || 'undef'
MC/DC50%1/2
not $types or (builtin::reftype($types) || "undef") ne "ARRAY"
not $types
builtin::reftype($types)
Truth table66%2/3
not(A) or B
A= not $typesB= builtin::reftype($types)
| |||||||||||||||||||||||||||||||||
| 535 | 3 | $self->{'type_cache'} = $types; | |||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||
| 537 | 3 | return clone $types; | |||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||
| 540 | 13 | ▶ | sub getCaseTypeByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getCaseTypeByName: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 541 | 13 | state $check = compile( Object, Str ); | |||||||||||||||||||||||||||||||
| 542 | 13 | my ( $self, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||
| 544 | 12 | my $types = $self->getCaseTypes(); | |||||||||||||||||||||||||||||||
| 545 | 12 | ▶ | return -500 if !$types || ( reftype($types) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $types or (builtin::reftype($types) || "undef") ne "ARRAY"
builtin::reftype($types) || 'undef'
MC/DC50%1/2
not $types or (builtin::reftype($types) || "undef") ne "ARRAY"
not $types
builtin::reftype($types)
Truth table66%2/3
not(A) or B
A= not $typesB= builtin::reftype($types)
| |||||||||||||||||||||||||||||||||
| 546 | 10 | foreach my $type (@$types) { | |||||||||||||||||||||||||||||||
| 547 | 16 | ▶ | return $type if $type->{'name'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||
| 549 | 0 | confess("No such case type '$name'!"); | |||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | sub typeNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
typeNamesToIds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 553 | 1 | my ( $self, @names ) = @_; | |||||||||||||||||||||||||||||||
| 554 | 1 | return _X_in_my_Y( $self, $self->getCaseTypes(), 'id', @names ); | |||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||
| 557 | 5 | ▶ | sub createCase { | ||||||||||||||||||||||||||||||
|
Subroutine
createCase: called CC=10 SCAR=37.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 558 | 5 | state $check = compile( | |||||||||||||||||||||||||||||||
| 559 | Object, Int, Str, | ||||||||||||||||||||||||||||||||
| 560 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 561 | Optional [ Maybe [HashRef] ], | ||||||||||||||||||||||||||||||||
| 562 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 563 | ); | ||||||||||||||||||||||||||||||||
| 564 | 5 | my ( $self, $section_id, $title, $type_id, $opts, $extras ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||
| 566 | 3 | my $stuff = { | |||||||||||||||||||||||||||||||
| 567 | title => $title, | ||||||||||||||||||||||||||||||||
| 568 | type_id => $type_id | ||||||||||||||||||||||||||||||||
| 569 | }; | ||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | #Handle sort of optional but baked in options | ||||||||||||||||||||||||||||||||
| 572 | 3 | ▶ | if ( defined($extras) && reftype($extras) eq 'HASH' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $extras and builtin::reftype($extras) eq "HASH"
MC/DC0%0/2
defined $extras and builtin::reftype($extras) eq "HASH"
defined $extras
builtin::reftype($extras) eq "HASH"
Truth table33%1/3
A and B
A= defined $extrasB= builtin::reftype($extras) eq "HASH"
| |||||||||||||||||||||||||||||||||
| 573 | $stuff->{'priority_id'} = $extras->{'priority_id'} | ||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | if defined( $extras->{'priority_id'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 575 | $stuff->{'estimate'} = $extras->{'estimate'} | ||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if defined( $extras->{'estimate'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 577 | $stuff->{'milestone_id'} = $extras->{'milestone_id'} | ||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if defined( $extras->{'milestone_id'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 579 | 0 | $stuff->{'refs'} = join( ',', @{ $extras->{'refs'} } ) | |||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if defined( $extras->{'refs'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||
| 583 | #Handle custom fields | ||||||||||||||||||||||||||||||||
| 584 | 3 | ▶ | if ( defined($opts) && reftype($opts) eq 'HASH' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $opts and builtin::reftype($opts) eq "HASH"
MC/DC0%0/2
defined $opts and builtin::reftype($opts) eq "HASH"
defined $opts
builtin::reftype($opts) eq "HASH"
Truth table33%1/3
A and B
A= defined $optsB= builtin::reftype($opts) eq "HASH"
| |||||||||||||||||||||||||||||||||
| 585 | 0 | foreach my $key ( keys(%$opts) ) { | |||||||||||||||||||||||||||||||
| 586 | 0 | $stuff->{"custom_$key"} = $opts->{$key}; | |||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||
| 590 | 3 | return $self->_doRequest( "index.php?/api/v2/add_case/$section_id", | |||||||||||||||||||||||||||||||
| 591 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||
| 594 | 1 | ▶ | sub updateCase { | ||||||||||||||||||||||||||||||
|
Subroutine
updateCase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 595 | 1 | state $check = compile( Object, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 596 | 1 | my ( $self, $case_id, $options ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | 1 | return $self->_doRequest( "index.php?/api/v2/update_case/$case_id", | |||||||||||||||||||||||||||||||
| 599 | 'POST', $options ); | ||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||
| 602 | 4 | ▶ | sub deleteCase { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteCase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 603 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 604 | 4 | my ( $self, $case_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||
| 606 | 3 | return $self->_doRequest( "index.php?/api/v2/delete_case/$case_id", | |||||||||||||||||||||||||||||||
| 607 | 'POST' ); | ||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||
| 610 | 24 | ▶ | sub getCases { | ||||||||||||||||||||||||||||||
|
Subroutine
getCases: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 611 | 24 | state $check = compile( Object, Int, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 612 | 24 | my ( $self, $project_id, $suite_id, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||
| 614 | 22 | my $url = "index.php?/api/v2/get_cases/$project_id&suite_id=$suite_id"; | |||||||||||||||||||||||||||||||
| 615 | 22 | $url .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||
| 617 | 22 | my $response = $self->_doRequest($url); | |||||||||||||||||||||||||||||||
| 618 | 22 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 619 | 15 | my $cases = $response->{'cases'}; | |||||||||||||||||||||||||||||||
| 620 | 15 | ▶ | return -500 if !$cases || ( reftype($cases) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $cases or (builtin::reftype($cases) || "undef") ne "ARRAY"
builtin::reftype($cases) || 'undef'
MC/DC0%0/2
not $cases or (builtin::reftype($cases) || "undef") ne "ARRAY"
not $cases
builtin::reftype($cases)
Truth table33%1/3
not(A) or B
A= not $casesB= builtin::reftype($cases)
| |||||||||||||||||||||||||||||||||
| 621 | 15 | return $cases; | |||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||
| 624 | 7 | ▶ | sub getCaseByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getCaseByName: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 625 | 7 | state $check = | |||||||||||||||||||||||||||||||
| 626 | compile( Object, Int, Int, Str, Optional [ Maybe [HashRef] ] ); | ||||||||||||||||||||||||||||||||
| 627 | 7 | my ( $self, $project_id, $suite_id, $name, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||
| 629 | 4 | my $cases = $self->getCases( $project_id, $suite_id, $filters ); | |||||||||||||||||||||||||||||||
| 630 | 4 | ▶ | return -500 if !$cases || ( reftype($cases) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $cases or (builtin::reftype($cases) || "undef") ne "ARRAY"
builtin::reftype($cases) || 'undef'
MC/DC50%1/2
not $cases or (builtin::reftype($cases) || "undef") ne "ARRAY"
not $cases
builtin::reftype($cases)
Truth table66%2/3
not(A) or B
A= not $casesB= builtin::reftype($cases)
| |||||||||||||||||||||||||||||||||
| 631 | 1 | foreach my $case (@$cases) { | |||||||||||||||||||||||||||||||
| 632 | 1 | ▶ | return $case if $case->{'title'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||
| 634 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||
| 637 | 4 | ▶ | sub getCaseByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getCaseByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 638 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 639 | 4 | my ( $self, $case_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||
| 641 | 3 | return $self->_doRequest("index.php?/api/v2/get_case/$case_id"); | |||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||
| 644 | 3 | ▶ | sub getCaseFields { | ||||||||||||||||||||||||||||||
|
Subroutine
getCaseFields: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 645 | 3 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 646 | 3 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 647 | 3 | ▶ | return $self->{case_fields} if $self->{case_fields}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||
| 649 | $self->{case_fields} = | ||||||||||||||||||||||||||||||||
| 650 | 2 | $self->_doRequest("index.php?/api/v2/get_case_fields"); | |||||||||||||||||||||||||||||||
| 651 | 2 | return $self->{case_fields}; | |||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | sub addCaseField { | ||||||||||||||||||||||||||||||
|
Subroutine
addCaseField: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 655 | 1 | state $check = compile( Object, slurpy HashRef ); | |||||||||||||||||||||||||||||||
| 656 | 1 | my ( $self, $options ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 657 | 1 | $self->{case_fields} = undef; | |||||||||||||||||||||||||||||||
| 658 | 1 | return $self->_doRequest( "index.php?/api/v2/add_case_field", 'POST', | |||||||||||||||||||||||||||||||
| 659 | $options ); | ||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||
| 662 | 4 | ▶ | sub getPriorities { | ||||||||||||||||||||||||||||||
|
Subroutine
getPriorities: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 663 | 4 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 664 | 4 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 665 | return clone( $self->{'priority_cache'} ) | ||||||||||||||||||||||||||||||||
| 666 | 4 | ▶ | if defined( $self->{'priority_cache'} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||
| 668 | 2 | my $priorities = $self->_doRequest("index.php?/api/v2/get_priorities"); | |||||||||||||||||||||||||||||||
| 669 | 2 | ▶ | return -500 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $priorities or (builtin::reftype($priorities) || "undef") ne "ARRAY"
builtin::reftype($priorities) || 'undef'
MC/DC50%1/2
not $priorities or (builtin::reftype($priorities) || "undef") ne "ARRAY"
not $priorities
builtin::reftype($priorities)
Truth table66%2/3
not(A) or B
A= not $prioritiesB= builtin::reftype($priorities)
| |||||||||||||||||||||||||||||||||
| 670 | if !$priorities || ( reftype($priorities) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 671 | 1 | $self->{'priority_cache'} = $priorities; | |||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||
| 673 | 1 | return clone $priorities; | |||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | 2 | ▶ | sub getPriorityByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getPriorityByName: called CC=6 SCAR=20.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 677 | 2 | state $check = compile( Object, Str ); | |||||||||||||||||||||||||||||||
| 678 | 2 | my ( $self, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||
| 680 | 1 | my $priorities = $self->getPriorities(); | |||||||||||||||||||||||||||||||
| 681 | 1 | ▶ | return -500 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $priorities or (builtin::reftype($priorities) || "undef") ne "ARRAY"
builtin::reftype($priorities) || 'undef'
MC/DC0%0/2
not $priorities or (builtin::reftype($priorities) || "undef") ne "ARRAY"
not $priorities
builtin::reftype($priorities)
Truth table33%1/3
not(A) or B
A= not $prioritiesB= builtin::reftype($priorities)
| |||||||||||||||||||||||||||||||||
| 682 | if !$priorities || ( reftype($priorities) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 683 | 1 | foreach my $priority (@$priorities) { | |||||||||||||||||||||||||||||||
| 684 | 1 | ▶ | return $priority if $priority->{'name'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||
| 686 | 0 | confess("No such priority '$name'!"); | |||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||
| 689 | 1 | ▶ | sub priorityNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
priorityNamesToIds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 690 | 1 | my ( $self, @names ) = @_; | |||||||||||||||||||||||||||||||
| 691 | 1 | return _X_in_my_Y( $self, $self->getPriorities(), 'id', @names ); | |||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||
| 694 | #If you pass an array of case ids, it implies include_all is false | ||||||||||||||||||||||||||||||||
| 695 | 277 | ▶ | sub createRun { | ||||||||||||||||||||||||||||||
|
Subroutine
createRun: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 696 | 277 | state $check = compile( | |||||||||||||||||||||||||||||||
| 697 | Object, Int, Int, Str, | ||||||||||||||||||||||||||||||||
| 698 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 699 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 700 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 701 | Optional [ Maybe [ ArrayRef [Int] ] ] | ||||||||||||||||||||||||||||||||
| 702 | ); | ||||||||||||||||||||||||||||||||
| 703 | 277 | my ( $self, $project_id, $suite_id, $name, $desc, $milestone_id, | |||||||||||||||||||||||||||||||
| 704 | $assignedto_id, $case_ids ) | ||||||||||||||||||||||||||||||||
| 705 | = $check->(@_); | ||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | 274 | ▶ | my $stuff = { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 708 | suite_id => $suite_id, | ||||||||||||||||||||||||||||||||
| 709 | name => $name, | ||||||||||||||||||||||||||||||||
| 710 | description => $desc, | ||||||||||||||||||||||||||||||||
| 711 | milestone_id => $milestone_id, | ||||||||||||||||||||||||||||||||
| 712 | assignedto_id => $assignedto_id, | ||||||||||||||||||||||||||||||||
| 713 | include_all => defined($case_ids) ? 0 : 1, | ||||||||||||||||||||||||||||||||
| 714 | case_ids => $case_ids | ||||||||||||||||||||||||||||||||
| 715 | }; | ||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||
| 717 | 274 | return $self->_doRequest( "index.php?/api/v2/add_run/$project_id", | |||||||||||||||||||||||||||||||
| 718 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||
| 721 | 4 | ▶ | sub deleteRun { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteRun: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 722 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 723 | 4 | my ( $self, $run_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||
| 725 | 3 | return $self->_doRequest( "index.php?/api/v2/delete_run/$run_id", 'POST' ); | |||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||
| 728 | 112 | ▶ | sub getRuns { | ||||||||||||||||||||||||||||||
|
Subroutine
getRuns: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 729 | 112 | state $check = compile( Object, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 730 | 112 | my ( $self, $project_id, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||
| 732 | my $initial_runs = | ||||||||||||||||||||||||||||||||
| 733 | 111 | $self->getRunsPaginated( $project_id, $self->{'global_limit'}, | |||||||||||||||||||||||||||||||
| 734 | 0, $filters ); | ||||||||||||||||||||||||||||||||
| 735 | 111 | ▶ | return $initial_runs | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
builtin::reftype($initial_runs) || 'undef'
MC/DC100%1/1
builtin::reftype($initial_runs) || 'undef'
builtin::reftype($initial_runs)
Truth table100%2/2
A
A= builtin::reftype($initial_runs)
| |||||||||||||||||||||||||||||||||
| 736 | unless ( reftype($initial_runs) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 737 | 107 | my $runs = []; | |||||||||||||||||||||||||||||||
| 738 | 107 | push( @$runs, @$initial_runs ); | |||||||||||||||||||||||||||||||
| 739 | 107 | my $offset = 1; | |||||||||||||||||||||||||||||||
| 740 | 107 | ▶ | while ( scalar(@$initial_runs) == $self->{'global_limit'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 741 | $initial_runs = $self->getRunsPaginated( | ||||||||||||||||||||||||||||||||
| 742 | $project_id, | ||||||||||||||||||||||||||||||||
| 743 | $self->{'global_limit'}, | ||||||||||||||||||||||||||||||||
| 744 | 22 | ( $self->{'global_limit'} * $offset ), $filters | |||||||||||||||||||||||||||||||
| 745 | ); | ||||||||||||||||||||||||||||||||
| 746 | 22 | ▶ | return $initial_runs | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($initial_runs) || 'undef'
MC/DC0%0/1
builtin::reftype($initial_runs) || 'undef'
builtin::reftype($initial_runs)
Truth table50%1/2
A
A= builtin::reftype($initial_runs)
| |||||||||||||||||||||||||||||||||
| 747 | unless ( reftype($initial_runs) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 748 | 22 | push( @$runs, @$initial_runs ); | |||||||||||||||||||||||||||||||
| 749 | 22 | $offset++; | |||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||
| 751 | 107 | return $runs; | |||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||
| 754 | 135 | ▶ | sub getRunsPaginated { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunsPaginated: called CC=10 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 755 | 135 | state $check = compile( | |||||||||||||||||||||||||||||||
| 756 | Object, | ||||||||||||||||||||||||||||||||
| 757 | Int, | ||||||||||||||||||||||||||||||||
| 758 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 759 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 760 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 761 | ); | ||||||||||||||||||||||||||||||||
| 762 | 135 | my ( $self, $project_id, $limit, $offset, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||
| 764 | confess( "Limit greater than " . $self->{'global_limit'} ) | ||||||||||||||||||||||||||||||||
| 765 | 134 | ▶ | if $limit > $self->{'global_limit'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 766 | 134 | my $apiurl = "index.php?/api/v2/get_runs/$project_id"; | |||||||||||||||||||||||||||||||
| 767 | 134 | ▶ | $apiurl .= "&offset=$offset" if defined($offset); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 768 | 134 | ▶ | $apiurl .= "&limit=$limit" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 769 | if $limit; #You have problems if you want 0 results | ||||||||||||||||||||||||||||||||
| 770 | 134 | $apiurl .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 771 | 134 | my $response = $self->_doRequest($apiurl); | |||||||||||||||||||||||||||||||
| 772 | 134 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 773 | 129 | my $runs = $response->{'runs'}; | |||||||||||||||||||||||||||||||
| 774 | 129 | ▶ | return -500 if !$runs || ( reftype($runs) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $runs or (builtin::reftype($runs) || "undef") ne "ARRAY"
builtin::reftype($runs) || 'undef'
MC/DC0%0/2
not $runs or (builtin::reftype($runs) || "undef") ne "ARRAY"
not $runs
builtin::reftype($runs)
Truth table33%1/3
not(A) or B
A= not $runsB= builtin::reftype($runs)
| |||||||||||||||||||||||||||||||||
| 775 | 129 | return $runs; | |||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||
| 778 | 60 | ▶ | sub getRunByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunByName: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 779 | 60 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 780 | 60 | my ( $self, $project_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||
| 782 | 58 | my $runs = $self->getRuns($project_id); | |||||||||||||||||||||||||||||||
| 783 | 58 | ▶ | return -500 if !$runs || ( reftype($runs) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $runs or (builtin::reftype($runs) || "undef") ne "ARRAY"
builtin::reftype($runs) || 'undef'
MC/DC50%1/2
not $runs or (builtin::reftype($runs) || "undef") ne "ARRAY"
not $runs
builtin::reftype($runs)
Truth table66%2/3
not(A) or B
A= not $runsB= builtin::reftype($runs)
| |||||||||||||||||||||||||||||||||
| 784 | 56 | foreach my $run (@$runs) { | |||||||||||||||||||||||||||||||
| 785 | 178 | ▶ | return $run if $run->{'name'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||
| 787 | 19 | return 0; | |||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||
| 790 | 6 | ▶ | sub getRunByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 791 | 6 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 792 | 6 | my ( $self, $run_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||
| 794 | 5 | return $self->_doRequest("index.php?/api/v2/get_run/$run_id"); | |||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||
| 797 | 4 | ▶ | sub closeRun { | ||||||||||||||||||||||||||||||
|
Subroutine
closeRun: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 798 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 799 | 4 | my ( $self, $run_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||
| 801 | 4 | return $self->_doRequest( "index.php?/api/v2/close_run/$run_id", 'POST' ); | |||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||
| 804 | 14 | ▶ | sub getRunSummary { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunSummary: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 805 | 14 | state $check = compile( Object, slurpy ArrayRef [HashRef] ); | |||||||||||||||||||||||||||||||
| 806 | 14 | my ( $self, $runs ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 807 | 14 | ▶ | confess("At least one run must be passed!") unless scalar(@$runs); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||
| 809 | #Translate custom statuses | ||||||||||||||||||||||||||||||||
| 810 | 13 | my $statuses = $self->getPossibleTestStatuses(); | |||||||||||||||||||||||||||||||
| 811 | 13 | my %shash; | |||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||
| 813 | #XXX so, they do these tricks with the status names, see...so map the counts to their relevant status ids. | ||||||||||||||||||||||||||||||||
| 814 | @shash{ | ||||||||||||||||||||||||||||||||
| 815 | map { | ||||||||||||||||||||||||||||||||
| 816 | ( $_->{'id'} < 6 ) | ||||||||||||||||||||||||||||||||
| 817 | ? $_->{'name'} . "_count" | ||||||||||||||||||||||||||||||||
| 818 | : "custom_status" | ||||||||||||||||||||||||||||||||
| 819 | 117 | ▶ | . ( $_->{'id'} - 5 ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 820 | . "_count" | ||||||||||||||||||||||||||||||||
| 821 | } @$statuses | ||||||||||||||||||||||||||||||||
| 822 | 13 | } = map { $_->{'id'} } @$statuses; | |||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||
| 824 | 13 | my @sname; | |||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||
| 826 | #Create listing of keys/values | ||||||||||||||||||||||||||||||||
| 827 | @$runs = map { | ||||||||||||||||||||||||||||||||
| 828 | 13 | my $run = $_; | |||||||||||||||||||||||||||||||
| 829 | 7833 | @{ $run->{statuses} }{ grep { $_ =~ m/_count$/ } keys(%$run) } = | |||||||||||||||||||||||||||||||
| 830 | 282 | grep { $_ =~ m/_count$/ } keys(%$run); | |||||||||||||||||||||||||||||||
| 831 | 282 | foreach my $status ( keys( %{ $run->{'statuses'} } ) ) { | |||||||||||||||||||||||||||||||
| 832 | 3348 | ▶ | next if !exists( $shash{$status} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 833 | @sname = grep { | ||||||||||||||||||||||||||||||||
| 834 | 2511 | exists( $shash{$status} ) | |||||||||||||||||||||||||||||||
| 835 | 22599 | ▶ | && $_->{'id'} == $shash{$status} | ||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $shash{$status} && $_->{'id'} == $shash{$status}
MC/DC50%1/2
exists $shash{$status} && $_->{'id'} == $shash{$status}
exists $shash{$status}
$_->{'id'} == $shash{$status}
Truth table66%2/3
A && B
A= exists $shash{$status}B= $_->{'id'} == $shash{$status}
| |||||||||||||||||||||||||||||||||
| 836 | } @$statuses; | ||||||||||||||||||||||||||||||||
| 837 | $run->{'statuses_clean'}->{ $sname[0]->{'label'} } = | ||||||||||||||||||||||||||||||||
| 838 | 2511 | $run->{$status}; | |||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||
| 840 | 282 | $run; | |||||||||||||||||||||||||||||||
| 841 | } @$runs; | ||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||
| 843 | return map { | ||||||||||||||||||||||||||||||||
| 844 | 13 | { | |||||||||||||||||||||||||||||||
| 845 | 'id' => $_->{'id'}, | ||||||||||||||||||||||||||||||||
| 846 | 'name' => $_->{'name'}, | ||||||||||||||||||||||||||||||||
| 847 | 'run_status' => $_->{'statuses_clean'}, | ||||||||||||||||||||||||||||||||
| 848 | 282 | 'config_ids' => $_->{'config_ids'} | |||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||
| 850 | } @$runs; | ||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||
| 854 | 1 | ▶ | sub getRunResults { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunResults: called CC=6 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 855 | 1 | state $check = compile( Object, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 856 | 1 | my ( $self, $run_id, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||
| 858 | my $initial_results = | ||||||||||||||||||||||||||||||||
| 859 | 1 | $self->getRunResultsPaginated( $run_id, $self->{'global_limit'}, | |||||||||||||||||||||||||||||||
| 860 | undef, $filters ); | ||||||||||||||||||||||||||||||||
| 861 | 1 | ▶ | return $initial_results | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($initial_results) || 'undef'
MC/DC0%0/1
builtin::reftype($initial_results) || 'undef'
builtin::reftype($initial_results)
Truth table50%1/2
A
A= builtin::reftype($initial_results)
| |||||||||||||||||||||||||||||||||
| 862 | unless ( reftype($initial_results) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 863 | 1 | my $results = []; | |||||||||||||||||||||||||||||||
| 864 | 1 | push( @$results, @$initial_results ); | |||||||||||||||||||||||||||||||
| 865 | 1 | my $offset = 1; | |||||||||||||||||||||||||||||||
| 866 | 1 | ▶ | while ( scalar(@$initial_results) == $self->{'global_limit'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 867 | $initial_results = $self->getRunResultsPaginated( | ||||||||||||||||||||||||||||||||
| 868 | $run_id, | ||||||||||||||||||||||||||||||||
| 869 | $self->{'global_limit'}, | ||||||||||||||||||||||||||||||||
| 870 | 0 | ( $self->{'global_limit'} * $offset ), $filters | |||||||||||||||||||||||||||||||
| 871 | ); | ||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | return $initial_results | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::reftype($initial_results) || 'undef'
MC/DC0%0/1
builtin::reftype($initial_results) || 'undef'
builtin::reftype($initial_results)
Truth table0%0/2
A
A= builtin::reftype($initial_results)
| |||||||||||||||||||||||||||||||||
| 873 | unless ( reftype($initial_results) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 874 | 0 | push( @$results, @$initial_results ); | |||||||||||||||||||||||||||||||
| 875 | 0 | $offset++; | |||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||
| 877 | 1 | return $results; | |||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||
| 880 | 1 | ▶ | sub getRunResultsPaginated { | ||||||||||||||||||||||||||||||
|
Subroutine
getRunResultsPaginated: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 881 | 1 | state $check = compile( | |||||||||||||||||||||||||||||||
| 882 | Object, | ||||||||||||||||||||||||||||||||
| 883 | Int, | ||||||||||||||||||||||||||||||||
| 884 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 885 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 886 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 887 | ); | ||||||||||||||||||||||||||||||||
| 888 | 1 | my ( $self, $run_id, $limit, $offset, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||
| 890 | confess( "Limit greater than " . $self->{'global_limit'} ) | ||||||||||||||||||||||||||||||||
| 891 | 1 | ▶ | if $limit > $self->{'global_limit'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 892 | 1 | my $apiurl = "index.php?/api/v2/get_results_for_run/$run_id"; | |||||||||||||||||||||||||||||||
| 893 | 1 | ▶ | $apiurl .= "&offset=$offset" if defined($offset); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 894 | 1 | ▶ | $apiurl .= "&limit=$limit" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 895 | if $limit; #You have problems if you want 0 results | ||||||||||||||||||||||||||||||||
| 896 | 1 | $apiurl .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 897 | 1 | my $response = $self->_doRequest($apiurl); | |||||||||||||||||||||||||||||||
| 898 | 1 | return $response->{'results'}; | |||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||
| 901 | 2432 | ▶ | sub getChildRuns { | ||||||||||||||||||||||||||||||
|
Subroutine
getChildRuns: called CC=8 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 902 | 2432 | state $check = compile( Object, HashRef ); | |||||||||||||||||||||||||||||||
| 903 | 2432 | my ( $self, $plan ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||
| 905 | return 0 | ||||||||||||||||||||||||||||||||
| 906 | unless defined( $plan->{'entries'} ) | ||||||||||||||||||||||||||||||||
| 907 | 2431 | ▶ | && ( reftype( $plan->{'entries'} ) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $plan->{"entries"} and (builtin::reftype($plan->{"entries"}) || "undef") eq "ARRAY"
builtin::reftype($plan->{'entries'}) || 'undef'
MC/DC50%1/2
defined $plan->{"entries"} and (builtin::reftype($plan->{"entries"}) || "undef") eq "ARRAY"
defined $plan->{"entries"}
builtin::reftype($plan->{'entries'})
Truth table66%2/3
A and B
A= defined $plan->{"entries"}B= builtin::reftype($plan->{'entries'})
| |||||||||||||||||||||||||||||||||
| 908 | 2429 | my $entries = $plan->{'entries'}; | |||||||||||||||||||||||||||||||
| 909 | 2429 | my $plans = []; | |||||||||||||||||||||||||||||||
| 910 | 2429 | foreach my $entry (@$entries) { | |||||||||||||||||||||||||||||||
| 911 | 2458 | push( @$plans, @{ $entry->{'runs'} } ) | |||||||||||||||||||||||||||||||
| 912 | if defined( $entry->{'runs'} ) | ||||||||||||||||||||||||||||||||
| 913 | 2458 | ▶ | && ( ( reftype( $entry->{'runs'} ) || 'undef' ) eq 'ARRAY' ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
defined $entry->{"runs"} and (builtin::reftype($entry->{"runs"}) || "undef") eq "ARRAY"
builtin::reftype($entry->{'runs'}) || 'undef'
MC/DC0%0/2
defined $entry->{"runs"} and (builtin::reftype($entry->{"runs"}) || "undef") eq "ARRAY"
defined $entry->{"runs"}
builtin::reftype($entry->{'runs'})
Truth table33%1/3
A and B
A= defined $entry->{"runs"}B= builtin::reftype($entry->{'runs'})
| |||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||
| 915 | 2429 | return $plans; | |||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||
| 918 | 42 | ▶ | sub getChildRunByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getChildRunByName: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 919 | 42 | state $check = compile( | |||||||||||||||||||||||||||||||
| 920 | Object, HashRef, Str, | ||||||||||||||||||||||||||||||||
| 921 | Optional [ Maybe [ ArrayRef [Str] ] ], | ||||||||||||||||||||||||||||||||
| 922 | Optional [ Maybe [Int] ] | ||||||||||||||||||||||||||||||||
| 923 | ); | ||||||||||||||||||||||||||||||||
| 924 | 42 | my ( $self, $plan, $name, $configurations, $testsuite_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||
| 926 | 40 | my $runs = $self->getChildRuns($plan); | |||||||||||||||||||||||||||||||
| 927 | 40 | ▶ | @$runs = grep { $_->{suite_id} == $testsuite_id } @$runs if $testsuite_id; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 928 | 40 | ▶ | return 0 if !$runs; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||
| 930 | 39 | my @pconfigs = (); | |||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||
| 932 | #Figure out desired config IDs | ||||||||||||||||||||||||||||||||
| 933 | 39 | ▶ | if ( defined $configurations ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 934 | 38 | my $avail_configs = $self->getConfigurations( $plan->{'project_id'} ); | |||||||||||||||||||||||||||||||
| 935 | 38 | my ($cname); | |||||||||||||||||||||||||||||||
| 936 | 36 | @pconfigs = map { $_->{'id'} } grep { | |||||||||||||||||||||||||||||||
| 937 | 38 | $cname = $_->{'name'}; | |||||||||||||||||||||||||||||||
| 938 | 158 | grep { $_ eq $cname } @$configurations | |||||||||||||||||||||||||||||||
| 939 | } @$avail_configs; #Get a list of IDs from the names passed | ||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||
| 941 | 39 | ▶ | confess("One or more configurations passed does not exist in your project!") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $configurations and scalar @pconfigs != scalar @$configurations
MC/DC0%0/2
defined $configurations and scalar @pconfigs != scalar @$configurations
defined $configurations
scalar @pconfigs != scalar @$configurations
Truth table66%2/3
A and B
A= defined $configurationsB= scalar @pconfigs != scalar @$configurations
| |||||||||||||||||||||||||||||||||
| 942 | if defined($configurations) | ||||||||||||||||||||||||||||||||
| 943 | && ( scalar(@pconfigs) != scalar(@$configurations) ); | ||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||
| 945 | 39 | my $found; | |||||||||||||||||||||||||||||||
| 946 | 39 | foreach my $run (@$runs) { | |||||||||||||||||||||||||||||||
| 947 | 38 | ▶ | next if $run->{name} ne $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 948 | 35 | ▶ | next if scalar(@pconfigs) != scalar( @{ $run->{'config_ids'} } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||
| 950 | #Compare run config IDs against desired, invalidate run if all conditions not satisfied | ||||||||||||||||||||||||||||||||
| 951 | 34 | $found = 0; | |||||||||||||||||||||||||||||||
| 952 | 34 | foreach my $cid ( @{ $run->{'config_ids'} } ) { | |||||||||||||||||||||||||||||||
| 953 | 33 | ▶ | $found++ if grep { $_ == $cid } @pconfigs; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||
| 956 | 34 | ▶ | return $run if $found == scalar( @{ $run->{'config_ids'} } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 957 | } | ||||||||||||||||||||||||||||||||
| 958 | 7 | return 0; | |||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||
| 961 | 264 | ▶ | sub createPlan { | ||||||||||||||||||||||||||||||
|
Subroutine
createPlan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 962 | 264 | state $check = compile( | |||||||||||||||||||||||||||||||
| 963 | Object, Int, Str, | ||||||||||||||||||||||||||||||||
| 964 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 965 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 966 | Optional [ Maybe [ ArrayRef [HashRef] ] ] | ||||||||||||||||||||||||||||||||
| 967 | ); | ||||||||||||||||||||||||||||||||
| 968 | 264 | my ( $self, $project_id, $name, $desc, $milestone_id, $entries ) = | |||||||||||||||||||||||||||||||
| 969 | $check->(@_); | ||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||
| 971 | 262 | my $stuff = { | |||||||||||||||||||||||||||||||
| 972 | name => $name, | ||||||||||||||||||||||||||||||||
| 973 | description => $desc, | ||||||||||||||||||||||||||||||||
| 974 | milestone_id => $milestone_id, | ||||||||||||||||||||||||||||||||
| 975 | entries => $entries | ||||||||||||||||||||||||||||||||
| 976 | }; | ||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||
| 978 | 262 | return $self->_doRequest( "index.php?/api/v2/add_plan/$project_id", | |||||||||||||||||||||||||||||||
| 979 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||
| 982 | 4 | ▶ | sub deletePlan { | ||||||||||||||||||||||||||||||
|
Subroutine
deletePlan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 983 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 984 | 4 | my ( $self, $plan_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||
| 986 | 3 | return $self->_doRequest( "index.php?/api/v2/delete_plan/$plan_id", | |||||||||||||||||||||||||||||||
| 987 | 'POST' ); | ||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||
| 990 | 105 | ▶ | sub getPlans { | ||||||||||||||||||||||||||||||
|
Subroutine
getPlans: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 991 | 105 | state $check = compile( Object, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 992 | 105 | my ( $self, $project_id, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||
| 994 | my $initial_plans = | ||||||||||||||||||||||||||||||||
| 995 | 104 | $self->getPlansPaginated( $project_id, $self->{'global_limit'}, | |||||||||||||||||||||||||||||||
| 996 | 0, $filters ); | ||||||||||||||||||||||||||||||||
| 997 | 104 | ▶ | return $initial_plans | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
builtin::reftype($initial_plans) || 'undef'
MC/DC100%1/1
builtin::reftype($initial_plans) || 'undef'
builtin::reftype($initial_plans)
Truth table100%2/2
A
A= builtin::reftype($initial_plans)
| |||||||||||||||||||||||||||||||||
| 998 | unless ( reftype($initial_plans) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 999 | 100 | my $plans = []; | |||||||||||||||||||||||||||||||
| 1000 | 100 | push( @$plans, @$initial_plans ); | |||||||||||||||||||||||||||||||
| 1001 | 100 | my $offset = 1; | |||||||||||||||||||||||||||||||
| 1002 | 100 | ▶ | while ( scalar(@$initial_plans) == $self->{'global_limit'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1003 | $initial_plans = $self->getPlansPaginated( | ||||||||||||||||||||||||||||||||
| 1004 | $project_id, | ||||||||||||||||||||||||||||||||
| 1005 | $self->{'global_limit'}, | ||||||||||||||||||||||||||||||||
| 1006 | 19 | ( $self->{'global_limit'} * $offset ), $filters | |||||||||||||||||||||||||||||||
| 1007 | ); | ||||||||||||||||||||||||||||||||
| 1008 | 19 | ▶ | return $initial_plans | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($initial_plans) || 'undef'
MC/DC0%0/1
builtin::reftype($initial_plans) || 'undef'
builtin::reftype($initial_plans)
Truth table50%1/2
A
A= builtin::reftype($initial_plans)
| |||||||||||||||||||||||||||||||||
| 1009 | unless ( reftype($initial_plans) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 1010 | 19 | push( @$plans, @$initial_plans ); | |||||||||||||||||||||||||||||||
| 1011 | 19 | $offset++; | |||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||
| 1013 | 100 | return $plans; | |||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||
| 1016 | 125 | ▶ | sub getPlansPaginated { | ||||||||||||||||||||||||||||||
|
Subroutine
getPlansPaginated: called CC=10 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1017 | 125 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1018 | Object, | ||||||||||||||||||||||||||||||||
| 1019 | Int, | ||||||||||||||||||||||||||||||||
| 1020 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1021 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1022 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 1023 | ); | ||||||||||||||||||||||||||||||||
| 1024 | 125 | my ( $self, $project_id, $limit, $offset, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||
| 1026 | confess( "Limit greater than " . $self->{'global_limit'} ) | ||||||||||||||||||||||||||||||||
| 1027 | 124 | ▶ | if $limit > $self->{'global_limit'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1028 | 124 | my $apiurl = "index.php?/api/v2/get_plans/$project_id"; | |||||||||||||||||||||||||||||||
| 1029 | 124 | ▶ | $apiurl .= "&offset=$offset" if defined($offset); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1030 | 124 | ▶ | $apiurl .= "&limit=$limit" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1031 | if $limit; #You have problems if you want 0 results | ||||||||||||||||||||||||||||||||
| 1032 | 124 | $apiurl .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 1033 | 124 | my $response = $self->_doRequest($apiurl); | |||||||||||||||||||||||||||||||
| 1034 | 124 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 1035 | 119 | my $plans = $response->{'plans'}; | |||||||||||||||||||||||||||||||
| 1036 | 119 | ▶ | return -500 if !$plans || ( reftype($plans) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $plans or (builtin::reftype($plans) || "undef") ne "ARRAY"
builtin::reftype($plans) || 'undef'
MC/DC0%0/2
not $plans or (builtin::reftype($plans) || "undef") ne "ARRAY"
not $plans
builtin::reftype($plans)
Truth table33%1/3
not(A) or B
A= not $plansB= builtin::reftype($plans)
| |||||||||||||||||||||||||||||||||
| 1037 | 119 | return $plans; | |||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||
| 1040 | 51 | ▶ | sub getPlanByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getPlanByName: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1041 | 51 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1042 | 51 | my ( $self, $project_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||
| 1044 | 49 | my $plans = $self->getPlans($project_id); | |||||||||||||||||||||||||||||||
| 1045 | 49 | ▶ | return -500 if !$plans || ( reftype($plans) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $plans or (builtin::reftype($plans) || "undef") ne "ARRAY"
builtin::reftype($plans) || 'undef'
MC/DC50%1/2
not $plans or (builtin::reftype($plans) || "undef") ne "ARRAY"
not $plans
builtin::reftype($plans)
Truth table66%2/3
not(A) or B
A= not $plansB= builtin::reftype($plans)
| |||||||||||||||||||||||||||||||||
| 1046 | 47 | foreach my $plan (@$plans) { | |||||||||||||||||||||||||||||||
| 1047 | 856 | ▶ | if ( $plan->{'name'} eq $name ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1048 | 39 | return $self->getPlanByID( $plan->{'id'} ); | |||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||
| 1051 | 8 | return 0; | |||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||
| 1054 | 113 | ▶ | sub getPlanByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getPlanByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1055 | 113 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1056 | 113 | my ( $self, $plan_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||
| 1058 | 112 | return $self->_doRequest("index.php?/api/v2/get_plan/$plan_id"); | |||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||
| 1061 | 6 | ▶ | sub getPlanSummary { | ||||||||||||||||||||||||||||||
|
Subroutine
getPlanSummary: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1062 | 6 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1063 | 6 | my ( $self, $plan_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||
| 1065 | 5 | my $runs = $self->getPlanByID($plan_id); | |||||||||||||||||||||||||||||||
| 1066 | 5 | $runs = $self->getChildRuns($runs); | |||||||||||||||||||||||||||||||
| 1067 | 5 | @$runs = $self->getRunSummary( @{$runs} ); | |||||||||||||||||||||||||||||||
| 1068 | 5 | my $total_sum = 0; | |||||||||||||||||||||||||||||||
| 1069 | 5 | my $ret = { plan => $plan_id }; | |||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||
| 1071 | #Compile totals | ||||||||||||||||||||||||||||||||
| 1072 | 5 | foreach my $summary (@$runs) { | |||||||||||||||||||||||||||||||
| 1073 | 11 | my @elems = keys( %{ $summary->{'run_status'} } ); | |||||||||||||||||||||||||||||||
| 1074 | 11 | foreach my $key (@elems) { | |||||||||||||||||||||||||||||||
| 1075 | 99 | ▶ | $ret->{'totals'}->{$key} = 0 if !defined $ret->{'totals'}->{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1076 | 99 | $ret->{'totals'}->{$key} += $summary->{'run_status'}->{$key}; | |||||||||||||||||||||||||||||||
| 1077 | 99 | $total_sum += $summary->{'run_status'}->{$key}; | |||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||
| 1081 | #Compile percentages | ||||||||||||||||||||||||||||||||
| 1082 | 5 | foreach my $key ( keys( %{ $ret->{'totals'} } ) ) { | |||||||||||||||||||||||||||||||
| 1083 | 45 | ▶ | next if grep { $_ eq $key } qw{plan configs percentages}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1084 | $ret->{"percentages"}->{$key} = | ||||||||||||||||||||||||||||||||
| 1085 | 45 | sprintf( "%.2f%%", ( $ret->{'totals'}->{$key} / $total_sum ) * 100 ); | |||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||
| 1088 | 5 | return $ret; | |||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||
| 1091 | #If you pass an array of case ids, it implies include_all is false | ||||||||||||||||||||||||||||||||
| 1092 | 14 | ▶ | sub createRunInPlan { | ||||||||||||||||||||||||||||||
|
Subroutine
createRunInPlan: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1093 | 14 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1094 | Object, Int, Int, Str, | ||||||||||||||||||||||||||||||||
| 1095 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1096 | Optional [ Maybe [ ArrayRef [Int] ] ], | ||||||||||||||||||||||||||||||||
| 1097 | Optional [ Maybe [ ArrayRef [Int] ] ] | ||||||||||||||||||||||||||||||||
| 1098 | ); | ||||||||||||||||||||||||||||||||
| 1099 | 14 | my ( $self, $plan_id, $suite_id, $name, $assignedto_id, $config_ids, | |||||||||||||||||||||||||||||||
| 1100 | $case_ids ) | ||||||||||||||||||||||||||||||||
| 1101 | = $check->(@_); | ||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||
| 1103 | 11 | ▶ | my $runs = [ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1104 | { | ||||||||||||||||||||||||||||||||
| 1105 | config_ids => $config_ids, | ||||||||||||||||||||||||||||||||
| 1106 | include_all => defined($case_ids) ? 0 : 1, | ||||||||||||||||||||||||||||||||
| 1107 | case_ids => $case_ids | ||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||
| 1109 | ]; | ||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||
| 1111 | 11 | ▶ | my $stuff = { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1112 | suite_id => $suite_id, | ||||||||||||||||||||||||||||||||
| 1113 | name => $name, | ||||||||||||||||||||||||||||||||
| 1114 | assignedto_id => $assignedto_id, | ||||||||||||||||||||||||||||||||
| 1115 | include_all => defined($case_ids) ? 0 : 1, | ||||||||||||||||||||||||||||||||
| 1116 | case_ids => $case_ids, | ||||||||||||||||||||||||||||||||
| 1117 | config_ids => $config_ids, | ||||||||||||||||||||||||||||||||
| 1118 | runs => $runs | ||||||||||||||||||||||||||||||||
| 1119 | }; | ||||||||||||||||||||||||||||||||
| 1120 | 11 | return $self->_doRequest( "index.php?/api/v2/add_plan_entry/$plan_id", | |||||||||||||||||||||||||||||||
| 1121 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||
| 1124 | 6 | ▶ | sub closePlan { | ||||||||||||||||||||||||||||||
|
Subroutine
closePlan: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1125 | 6 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1126 | 6 | my ( $self, $plan_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||
| 1128 | 6 | return $self->_doRequest( "index.php?/api/v2/close_plan/$plan_id", 'POST' ); | |||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||
| 1131 | 5 | ▶ | sub createMilestone { | ||||||||||||||||||||||||||||||
|
Subroutine
createMilestone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1132 | 5 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1133 | Object, Int, Str, | ||||||||||||||||||||||||||||||||
| 1134 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 1135 | Optional [ Maybe [Int] ] | ||||||||||||||||||||||||||||||||
| 1136 | ); | ||||||||||||||||||||||||||||||||
| 1137 | 5 | my ( $self, $project_id, $name, $desc, $due_on ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||
| 1139 | 3 | my $stuff = { | |||||||||||||||||||||||||||||||
| 1140 | name => $name, | ||||||||||||||||||||||||||||||||
| 1141 | description => $desc, | ||||||||||||||||||||||||||||||||
| 1142 | due_on => $due_on # unix timestamp | ||||||||||||||||||||||||||||||||
| 1143 | }; | ||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||
| 1145 | 3 | return $self->_doRequest( "index.php?/api/v2/add_milestone/$project_id", | |||||||||||||||||||||||||||||||
| 1146 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||
| 1149 | 4 | ▶ | sub deleteMilestone { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteMilestone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1150 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1151 | 4 | my ( $self, $milestone_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||
| 1153 | 3 | return $self->_doRequest( | |||||||||||||||||||||||||||||||
| 1154 | "index.php?/api/v2/delete_milestone/$milestone_id", 'POST' ); | ||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||
| 1157 | 7 | ▶ | sub getMilestones { | ||||||||||||||||||||||||||||||
|
Subroutine
getMilestones: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1158 | 7 | state $check = compile( Object, Int, Optional [ Maybe [HashRef] ] ); | |||||||||||||||||||||||||||||||
| 1159 | 7 | my ( $self, $project_id, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||
| 1161 | 6 | my $response = | |||||||||||||||||||||||||||||||
| 1162 | $self->_doRequest( "index.php?/api/v2/get_milestones/$project_id" | ||||||||||||||||||||||||||||||||
| 1163 | . _convert_filters_to_string($filters) ); | ||||||||||||||||||||||||||||||||
| 1164 | 6 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 1165 | 2 | my $milestones = $response->{'milestones'}; | |||||||||||||||||||||||||||||||
| 1166 | 2 | ▶ | return -500 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $milestones or (builtin::reftype($milestones) || "undef") ne "ARRAY"
builtin::reftype($milestones) || 'undef'
MC/DC0%0/2
not $milestones or (builtin::reftype($milestones) || "undef") ne "ARRAY"
not $milestones
builtin::reftype($milestones)
Truth table33%1/3
not(A) or B
A= not $milestonesB= builtin::reftype($milestones)
| |||||||||||||||||||||||||||||||||
| 1167 | if !$milestones || ( reftype($milestones) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 1168 | 2 | return $milestones; | |||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||
| 1171 | 5 | ▶ | sub getMilestoneByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getMilestoneByName: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1172 | 5 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1173 | 5 | my ( $self, $project_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||
| 1175 | 3 | my $milestones = $self->getMilestones($project_id); | |||||||||||||||||||||||||||||||
| 1176 | 3 | ▶ | return -500 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $milestones or (builtin::reftype($milestones) || "undef") ne "ARRAY"
builtin::reftype($milestones) || 'undef'
MC/DC50%1/2
not $milestones or (builtin::reftype($milestones) || "undef") ne "ARRAY"
not $milestones
builtin::reftype($milestones)
Truth table66%2/3
not(A) or B
A= not $milestonesB= builtin::reftype($milestones)
| |||||||||||||||||||||||||||||||||
| 1177 | if !$milestones || ( reftype($milestones) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||
| 1178 | 1 | foreach my $milestone (@$milestones) { | |||||||||||||||||||||||||||||||
| 1179 | 1 | ▶ | return $milestone if $milestone->{'name'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||
| 1181 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||
| 1184 | 27 | ▶ | sub getMilestoneByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getMilestoneByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1185 | 27 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1186 | 27 | my ( $self, $milestone_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||
| 1188 | 26 | return $self->_doRequest("index.php?/api/v2/get_milestone/$milestone_id"); | |||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||
| 1191 | 92 | ▶ | sub getTests { | ||||||||||||||||||||||||||||||
|
Subroutine
getTests: called CC=13 SCAR=25.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1192 | 92 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1193 | Object, Int, | ||||||||||||||||||||||||||||||||
| 1194 | Optional [ Maybe [ ArrayRef [Int] ] ], | ||||||||||||||||||||||||||||||||
| 1195 | Optional [ Maybe [ ArrayRef [Int] ] ] | ||||||||||||||||||||||||||||||||
| 1196 | ); | ||||||||||||||||||||||||||||||||
| 1197 | 92 | my ( $self, $run_id, $status_ids, $assignedto_ids ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||
| 1199 | 91 | my $query_string = ''; | |||||||||||||||||||||||||||||||
| 1200 | 91 | ▶ | $query_string = '&status_id=' . join( ',', @$status_ids ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $status_ids and scalar @$status_ids
MC/DC100%1/1
defined $status_ids and scalar @$status_ids
defined $status_ids
Truth table100%2/2
A
A= defined $status_ids
| |||||||||||||||||||||||||||||||||
| 1201 | if defined($status_ids) && scalar(@$status_ids); | ||||||||||||||||||||||||||||||||
| 1202 | 91 | my $response = | |||||||||||||||||||||||||||||||
| 1203 | $self->_doRequest("index.php?/api/v2/get_tests/$run_id$query_string"); | ||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||
| 1205 | 91 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 1206 | 87 | my $results = $response->{'tests'}; | |||||||||||||||||||||||||||||||
| 1207 | 87 | ▶ | return -500 if !$results || ( reftype($results) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $results or (builtin::reftype($results) || "undef") ne "ARRAY"
builtin::reftype($results) || 'undef'
MC/DC0%0/2
not $results or (builtin::reftype($results) || "undef") ne "ARRAY"
not $results
builtin::reftype($results)
Truth table33%1/3
not(A) or B
A= not $resultsB= builtin::reftype($results)
| |||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||
| 1209 | @$results = grep { | ||||||||||||||||||||||||||||||||
| 1210 | 87 | ▶ | my $aid = $_->{'assignedto_id'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $assignedto_ids and scalar @$assignedto_ids
MC/DC100%1/1
defined $assignedto_ids and scalar @$assignedto_ids
defined $assignedto_ids
Truth table100%2/2
A
A= defined $assignedto_ids
| |||||||||||||||||||||||||||||||||
| 1211 | 22 | ▶ | grep { defined($aid) && $aid == $_ } @$assignedto_ids | ||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $aid && $aid == $_
MC/DC100%2/2
defined $aid && $aid == $_
defined $aid
$aid == $_
Truth table100%3/3
A && B
A= defined $aidB= $aid == $_
| |||||||||||||||||||||||||||||||||
| 1212 | } @$results if defined($assignedto_ids) && scalar(@$assignedto_ids); | ||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||
| 1214 | #Cache stuff for getTestByName | ||||||||||||||||||||||||||||||||
| 1215 | 87 | ▶ | $self->{tests_cache} //= {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"tests_cache"} //= {}
MC/DC100%1/1
$self->{"tests_cache"} //= {}
$self->{"tests_cache"}
Truth table100%2/2
A
A= $self->{"tests_cache"}
| |||||||||||||||||||||||||||||||||
| 1216 | 87 | $self->{tests_cache}->{$run_id} = $results; | |||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||
| 1218 | 87 | return clone($results); | |||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||
| 1221 | 51 | ▶ | sub getTestByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestByName: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1222 | 51 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1223 | 51 | my ( $self, $run_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||
| 1225 | 49 | ▶ | $self->{tests_cache} //= {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"tests_cache"} //= {}
MC/DC100%1/1
$self->{"tests_cache"} //= {}
$self->{"tests_cache"}
Truth table100%2/2
A
A= $self->{"tests_cache"}
| |||||||||||||||||||||||||||||||||
| 1226 | 49 | my $tests = $self->{tests_cache}->{$run_id}; | |||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||
| 1228 | 49 | ▶ | $tests = $self->getTests($run_id) if !$tests; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1229 | 49 | ▶ | return -500 if !$tests || ( reftype($tests) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $tests or (builtin::reftype($tests) || "undef") ne "ARRAY"
builtin::reftype($tests) || 'undef'
MC/DC50%1/2
not $tests or (builtin::reftype($tests) || "undef") ne "ARRAY"
not $tests
builtin::reftype($tests)
Truth table66%2/3
not(A) or B
A= not $testsB= builtin::reftype($tests)
| |||||||||||||||||||||||||||||||||
| 1230 | 47 | foreach my $test (@$tests) { | |||||||||||||||||||||||||||||||
| 1231 | 137 | ▶ | return $test if $test->{'title'} eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||
| 1233 | 1 | return 0; | |||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||
| 1236 | 4 | ▶ | sub getTestByID { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1237 | 4 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1238 | 4 | my ( $self, $test_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||
| 1240 | 3 | return $self->_doRequest("index.php?/api/v2/get_test/$test_id"); | |||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||
| 1243 | 20 | ▶ | sub getTestResultFields { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestResultFields: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1244 | 20 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 1245 | 20 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||
| 1247 | 20 | ▶ | return $self->{'tr_fields'} if defined( $self->{'tr_fields'} ); #cache | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1248 | 17 | $self->{'tr_fields'} = | |||||||||||||||||||||||||||||||
| 1249 | $self->_doRequest('index.php?/api/v2/get_result_fields'); | ||||||||||||||||||||||||||||||||
| 1250 | 17 | return $self->{'tr_fields'}; | |||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||
| 1253 | 18 | ▶ | sub getTestResultFieldByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestResultFieldByName: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1254 | 18 | state $check = compile( Object, Str, Optional [ Maybe [Int] ] ); | |||||||||||||||||||||||||||||||
| 1255 | 18 | my ( $self, $system_name, $project_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||
| 1257 | my @candidates = | ||||||||||||||||||||||||||||||||
| 1258 | 17 | grep { $_->{'name'} eq $system_name } @{ $self->getTestResultFields() }; | |||||||||||||||||||||||||||||||
| 1259 | 17 | ▶ | return 0 if !scalar(@candidates); #No such name | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1260 | 15 | ▶ | return -1 if ref( $candidates[0] ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1261 | return -2 | ||||||||||||||||||||||||||||||||
| 1262 | if ref( $candidates[0]->{'configs'} ) ne 'ARRAY' | ||||||||||||||||||||||||||||||||
| 1263 | 0 | ▶ | && !scalar( @{ $candidates[0]->{'configs'} } ); #bogofilter | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $candidates[0]{"configs"} ne "ARRAY" and not scalar @{$candidates[0]{"configs"};}
MC/DC0%0/2
ref $candidates[0]{"configs"} ne "ARRAY" and not scalar @{$candidates[0]{"configs"};}
ref $candidates[0]{"configs"} ne "ARRAY"
not scalar @{$candidates[0]{"configs"};}
Truth table33%1/3
A and not(B)
A= ref $candidates[0]{"configs"} ne "ARRAY"B= not scalar @{$candidates[0]{"configs"};}
| |||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||
| 1265 | #Give it to the user | ||||||||||||||||||||||||||||||||
| 1266 | 15 | my $ret = $candidates[0]; #copy/save for later | |||||||||||||||||||||||||||||||
| 1267 | 15 | ▶ | return $ret if !defined($project_id); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||
| 1269 | #Filter by project ID | ||||||||||||||||||||||||||||||||
| 1270 | 14 | foreach my $config ( @{ $candidates[0]->{'configs'} } ) { | |||||||||||||||||||||||||||||||
| 1271 | return $ret | ||||||||||||||||||||||||||||||||
| 1272 | 62 | if ( grep { $_ == $project_id } | |||||||||||||||||||||||||||||||
| 1273 | 34 | ▶ | @{ $config->{'context'}->{'project_ids'} } ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1274 | } | ||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||
| 1276 | 1 | return -3; | |||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||
| 1279 | 111 | ▶ | sub getPossibleTestStatuses { | ||||||||||||||||||||||||||||||
|
Subroutine
getPossibleTestStatuses: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1280 | 111 | state $check = compile(Object); | |||||||||||||||||||||||||||||||
| 1281 | 111 | my ($self) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1282 | 111 | ▶ | return $self->{'status_cache'} if $self->{'status_cache'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||
| 1284 | 81 | $self->{'status_cache'} = | |||||||||||||||||||||||||||||||
| 1285 | $self->_doRequest('index.php?/api/v2/get_statuses'); | ||||||||||||||||||||||||||||||||
| 1286 | 81 | return clone $self->{'status_cache'}; | |||||||||||||||||||||||||||||||
| 1287 | } | ||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||
| 1289 | 21 | ▶ | sub statusNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
statusNamesToIds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1290 | 21 | my ( $self, @names ) = @_; | |||||||||||||||||||||||||||||||
| 1291 | 21 | return _X_in_my_Y( $self, $self->getPossibleTestStatuses(), 'id', @names ); | |||||||||||||||||||||||||||||||
| 1292 | } | ||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||
| 1294 | 5 | ▶ | sub statusNamesToLabels { | ||||||||||||||||||||||||||||||
|
Subroutine
statusNamesToLabels: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1295 | 5 | my ( $self, @names ) = @_; | |||||||||||||||||||||||||||||||
| 1296 | 5 | return _X_in_my_Y( $self, $self->getPossibleTestStatuses(), 'label', | |||||||||||||||||||||||||||||||
| 1297 | @names ); | ||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||
| 1300 | # Reduce code duplication with internal methods? | ||||||||||||||||||||||||||||||||
| 1301 | # It's more likely than you think | ||||||||||||||||||||||||||||||||
| 1302 | # Free PC check @ cpan.org | ||||||||||||||||||||||||||||||||
| 1303 | 100 | ▶ | sub _X_in_my_Y { | ||||||||||||||||||||||||||||||
|
Subroutine
_X_in_my_Y: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 1304 | 100 | state $check = compile( Object, ArrayRef, Str, slurpy ArrayRef [Str] ); | |||||||||||||||||||||||||||||||
| 1305 | 100 | my ( $self, $search_arr, $key, $names ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||
| 1307 | 97 | my @ret; | |||||||||||||||||||||||||||||||
| 1308 | 97 | foreach my $name (@$names) { | |||||||||||||||||||||||||||||||
| 1309 | 127 | foreach my $member (@$search_arr) { | |||||||||||||||||||||||||||||||
| 1310 | 527 | ▶ | if ( $member->{'name'} eq $name ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1311 | 123 | push @ret, $member->{$key}; | |||||||||||||||||||||||||||||||
| 1312 | 123 | last; | |||||||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||
| 1316 | 97 | ▶ | confess("One or more names provided does not exist in TestRail.") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1317 | unless scalar(@$names) == scalar(@ret); | ||||||||||||||||||||||||||||||||
| 1318 | 93 | return @ret; | |||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||
| 1321 | 56 | ▶ | sub createTestResults { | ||||||||||||||||||||||||||||||
|
Subroutine
createTestResults: called CC=10 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1322 | 56 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1323 | Object, Int, Int, | ||||||||||||||||||||||||||||||||
| 1324 | Optional [ Maybe [Str] ], | ||||||||||||||||||||||||||||||||
| 1325 | Optional [ Maybe [HashRef] ], | ||||||||||||||||||||||||||||||||
| 1326 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 1327 | ); | ||||||||||||||||||||||||||||||||
| 1328 | 56 | my ( $self, $test_id, $status_id, $comment, $opts, $custom_fields ) = | |||||||||||||||||||||||||||||||
| 1329 | $check->(@_); | ||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||
| 1331 | 54 | my $stuff = { | |||||||||||||||||||||||||||||||
| 1332 | status_id => $status_id, | ||||||||||||||||||||||||||||||||
| 1333 | comment => $comment | ||||||||||||||||||||||||||||||||
| 1334 | }; | ||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||
| 1336 | #Handle options | ||||||||||||||||||||||||||||||||
| 1337 | 54 | ▶ | if ( defined($opts) && reftype($opts) eq 'HASH' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $opts and builtin::reftype($opts) eq "HASH"
MC/DC50%1/2
defined $opts and builtin::reftype($opts) eq "HASH"
defined $opts
builtin::reftype($opts) eq "HASH"
Truth table66%2/3
A and B
A= defined $optsB= builtin::reftype($opts) eq "HASH"
| |||||||||||||||||||||||||||||||||
| 1338 | $stuff->{'version'} = | ||||||||||||||||||||||||||||||||
| 1339 | 44 | ▶ | defined( $opts->{'version'} ) ? $opts->{'version'} : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1340 | $stuff->{'elapsed'} = | ||||||||||||||||||||||||||||||||
| 1341 | 44 | ▶ | defined( $opts->{'elapsed'} ) ? $opts->{'elapsed'} : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1342 | $stuff->{'defects'} = | ||||||||||||||||||||||||||||||||
| 1343 | defined( $opts->{'defects'} ) | ||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | ? join( ',', @{ $opts->{'defects'} } ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1345 | : undef; | ||||||||||||||||||||||||||||||||
| 1346 | $stuff->{'assignedto_id'} = | ||||||||||||||||||||||||||||||||
| 1347 | defined( $opts->{'assignedto_id'} ) | ||||||||||||||||||||||||||||||||
| 1348 | 44 | ▶ | ? $opts->{'assignedto_id'} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1349 | : undef; | ||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||
| 1352 | #Handle custom fields | ||||||||||||||||||||||||||||||||
| 1353 | 54 | ▶ | if ( defined($custom_fields) && reftype($custom_fields) eq 'HASH' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $custom_fields and builtin::reftype($custom_fields) eq "HASH"
MC/DC50%1/2
defined $custom_fields and builtin::reftype($custom_fields) eq "HASH"
defined $custom_fields
builtin::reftype($custom_fields) eq "HASH"
Truth table66%2/3
A and B
A= defined $custom_fieldsB= builtin::reftype($custom_fields) eq "HASH"
| |||||||||||||||||||||||||||||||||
| 1354 | 7 | foreach my $field ( keys(%$custom_fields) ) { | |||||||||||||||||||||||||||||||
| 1355 | 7 | $stuff->{"custom_$field"} = $custom_fields->{$field}; | |||||||||||||||||||||||||||||||
| 1356 | } | ||||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||
| 1359 | 54 | return $self->_doRequest( "index.php?/api/v2/add_result/$test_id", | |||||||||||||||||||||||||||||||
| 1360 | 'POST', $stuff ); | ||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||
| 1363 | 6 | ▶ | sub bulkAddResults { | ||||||||||||||||||||||||||||||
|
Subroutine
bulkAddResults: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1364 | 6 | state $check = compile( Object, Int, ArrayRef [HashRef] ); | |||||||||||||||||||||||||||||||
| 1365 | 6 | my ( $self, $run_id, $results ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||
| 1367 | 4 | return $self->_doRequest( "index.php?/api/v2/add_results/$run_id", | |||||||||||||||||||||||||||||||
| 1368 | 'POST', { 'results' => $results } ); | ||||||||||||||||||||||||||||||||
| 1369 | } | ||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||
| 1371 | 0 | ▶ | sub bulkAddResultsByCase { | ||||||||||||||||||||||||||||||
|
Subroutine
bulkAddResultsByCase: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1372 | 0 | state $check = compile( Object, Int, ArrayRef [HashRef] ); | |||||||||||||||||||||||||||||||
| 1373 | 0 | my ( $self, $run_id, $results ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||
| 1375 | 0 | return $self->_doRequest( "index.php?/api/v2/add_results_for_cases/$run_id", | |||||||||||||||||||||||||||||||
| 1376 | 'POST', { 'results' => $results } ); | ||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||
| 1379 | 12 | ▶ | sub getTestResults { | ||||||||||||||||||||||||||||||
|
Subroutine
getTestResults: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1380 | 12 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1381 | Object, | ||||||||||||||||||||||||||||||||
| 1382 | Int, | ||||||||||||||||||||||||||||||||
| 1383 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1384 | Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1385 | Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 1386 | ); | ||||||||||||||||||||||||||||||||
| 1387 | 12 | my ( $self, $test_id, $limit, $offset, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||
| 1389 | 11 | my $url = "index.php?/api/v2/get_results/$test_id"; | |||||||||||||||||||||||||||||||
| 1390 | 11 | ▶ | $url .= "&limit=$limit" if $limit; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1391 | 11 | ▶ | $url .= "&offset=$offset" if defined($offset); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1392 | 11 | $url .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 1393 | 11 | my $response = $self->_doRequest($url); | |||||||||||||||||||||||||||||||
| 1394 | 11 | ▶ | return -500 if !$response || ( reftype($response) || 'undef' ) ne 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
not $response or (builtin::reftype($response) || "undef") ne "HASH"
builtin::reftype($response) || 'undef'
MC/DC50%1/2
not $response or (builtin::reftype($response) || "undef") ne "HASH"
not $response
builtin::reftype($response)
Truth table66%2/3
not(A) or B
A= not $responseB= builtin::reftype($response)
| |||||||||||||||||||||||||||||||||
| 1395 | 9 | my $results = $response->{'results'}; | |||||||||||||||||||||||||||||||
| 1396 | 9 | ▶ | return -500 if !$results || ( reftype($results) || 'undef' ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
not $results or (builtin::reftype($results) || "undef") ne "ARRAY"
builtin::reftype($results) || 'undef'
MC/DC0%0/2
not $results or (builtin::reftype($results) || "undef") ne "ARRAY"
not $results
builtin::reftype($results)
Truth table33%1/3
not(A) or B
A= not $resultsB= builtin::reftype($results)
| |||||||||||||||||||||||||||||||||
| 1397 | 9 | return $results; | |||||||||||||||||||||||||||||||
| 1398 | } | ||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | sub getResultsForCase { | ||||||||||||||||||||||||||||||
|
Subroutine
getResultsForCase: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1401 | 0 | state $check = compile( | |||||||||||||||||||||||||||||||
| 1402 | Object, Int, | ||||||||||||||||||||||||||||||||
| 1403 | Int, Optional [ Maybe [Int] ], | ||||||||||||||||||||||||||||||||
| 1404 | Optional [ Maybe [Int] ], Optional [ Maybe [HashRef] ] | ||||||||||||||||||||||||||||||||
| 1405 | ); | ||||||||||||||||||||||||||||||||
| 1406 | 0 | my ( $self, $run_id, $case_id, $limit, $offset, $filters ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||||||
| 1408 | 0 | my $url = "index.php?/api/v2/get_results_for_case/$run_id/$case_id"; | |||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | $url .= "&limit=$limit" if $limit; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1410 | 0 | ▶ | $url .= "&offset=$offset" if defined($offset); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1411 | 0 | $url .= _convert_filters_to_string($filters); | |||||||||||||||||||||||||||||||
| 1412 | 0 | my $response = $self->_doRequest($url); | |||||||||||||||||||||||||||||||
| 1413 | 0 | return $response->{'results'}; | |||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||
| 1416 | 199 | ▶ | sub getConfigurationGroups { | ||||||||||||||||||||||||||||||
|
Subroutine
getConfigurationGroups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1417 | 199 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1418 | 199 | my ( $self, $project_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||
| 1420 | 198 | my $url = "index.php?/api/v2/get_configs/$project_id"; | |||||||||||||||||||||||||||||||
| 1421 | 198 | return $self->_doRequest($url); | |||||||||||||||||||||||||||||||
| 1422 | } | ||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||
| 1424 | 4 | ▶ | sub getConfigurationGroupByName { | ||||||||||||||||||||||||||||||
|
Subroutine
getConfigurationGroupByName: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1425 | 4 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1426 | 4 | my ( $self, $project_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||
| 1428 | 4 | my $cgroups = $self->getConfigurationGroups($project_id); | |||||||||||||||||||||||||||||||
| 1429 | 4 | ▶ | return 0 if ref($cgroups) ne 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1430 | 4 | @$cgroups = grep { $_->{'name'} eq $name } @$cgroups; | |||||||||||||||||||||||||||||||
| 1431 | 4 | ▶ | return 0 unless scalar(@$cgroups); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1432 | 1 | return $cgroups->[0]; | |||||||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||
| 1435 | 4 | ▶ | sub addConfigurationGroup { | ||||||||||||||||||||||||||||||
|
Subroutine
addConfigurationGroup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1436 | 4 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1437 | 4 | my ( $self, $project_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||
| 1439 | 4 | my $url = "index.php?/api/v2/add_config_group/$project_id"; | |||||||||||||||||||||||||||||||
| 1440 | 4 | return $self->_doRequest( $url, 'POST', { 'name' => $name } ); | |||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||
| 1443 | 1 | ▶ | sub editConfigurationGroup { | ||||||||||||||||||||||||||||||
|
Subroutine
editConfigurationGroup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1444 | 1 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1445 | 1 | my ( $self, $config_group_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1446 | |||||||||||||||||||||||||||||||||
| 1447 | 1 | my $url = "index.php?/api/v2/update_config_group/$config_group_id"; | |||||||||||||||||||||||||||||||
| 1448 | 1 | return $self->_doRequest( $url, 'POST', { 'name' => $name } ); | |||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||
| 1451 | 1 | ▶ | sub deleteConfigurationGroup { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteConfigurationGroup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1452 | 1 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1453 | 1 | my ( $self, $config_group_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||
| 1455 | 1 | my $url = "index.php?/api/v2/delete_config_group/$config_group_id"; | |||||||||||||||||||||||||||||||
| 1456 | 1 | return $self->_doRequest( $url, 'POST' ); | |||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||
| 1459 | 195 | ▶ | sub getConfigurations { | ||||||||||||||||||||||||||||||
|
Subroutine
getConfigurations: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1460 | 195 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1461 | 195 | my ( $self, $project_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||
| 1463 | 193 | my $cgroups = $self->getConfigurationGroups($project_id); | |||||||||||||||||||||||||||||||
| 1464 | 193 | my $configs = []; | |||||||||||||||||||||||||||||||
| 1465 | 193 | ▶ | return $cgroups unless ( reftype($cgroups) || 'undef' ) eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
builtin::reftype($cgroups) || 'undef'
MC/DC100%1/1
builtin::reftype($cgroups) || 'undef'
builtin::reftype($cgroups)
Truth table100%2/2
A
A= builtin::reftype($cgroups)
| |||||||||||||||||||||||||||||||||
| 1466 | 190 | foreach my $cfg (@$cgroups) { | |||||||||||||||||||||||||||||||
| 1467 | 378 | push( @$configs, @{ $cfg->{'configs'} } ); | |||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||
| 1469 | 190 | return $configs; | |||||||||||||||||||||||||||||||
| 1470 | } | ||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||
| 1472 | 4 | ▶ | sub addConfiguration { | ||||||||||||||||||||||||||||||
|
Subroutine
addConfiguration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1473 | 4 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1474 | 4 | my ( $self, $configuration_group_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||
| 1476 | 4 | my $url = "index.php?/api/v2/add_config/$configuration_group_id"; | |||||||||||||||||||||||||||||||
| 1477 | 4 | return $self->_doRequest( $url, 'POST', { 'name' => $name } ); | |||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||
| 1480 | 1 | ▶ | sub editConfiguration { | ||||||||||||||||||||||||||||||
|
Subroutine
editConfiguration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1481 | 1 | state $check = compile( Object, Int, Str ); | |||||||||||||||||||||||||||||||
| 1482 | 1 | my ( $self, $config_id, $name ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||
| 1484 | 1 | my $url = "index.php?/api/v2/update_config/$config_id"; | |||||||||||||||||||||||||||||||
| 1485 | 1 | return $self->_doRequest( $url, 'POST', { 'name' => $name } ); | |||||||||||||||||||||||||||||||
| 1486 | } | ||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||
| 1488 | 1 | ▶ | sub deleteConfiguration { | ||||||||||||||||||||||||||||||
|
Subroutine
deleteConfiguration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1489 | 1 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1490 | 1 | my ( $self, $config_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||
| 1492 | 1 | my $url = "index.php?/api/v2/delete_config/$config_id"; | |||||||||||||||||||||||||||||||
| 1493 | 1 | return $self->_doRequest( $url, 'POST' ); | |||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||
| 1496 | 61 | ▶ | sub translateConfigNamesToIds { | ||||||||||||||||||||||||||||||
|
Subroutine
translateConfigNamesToIds: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1497 | 61 | my ( $self, $project_id, @names ) = @_; | |||||||||||||||||||||||||||||||
| 1498 | 61 | ▶ | my $configs = $self->getConfigurations($project_id) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1499 | or confess("Could not determine configurations in provided project."); | ||||||||||||||||||||||||||||||||
| 1500 | 60 | return _X_in_my_Y( $self, $configs, 'id', @names ); | |||||||||||||||||||||||||||||||
| 1501 | } | ||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||
| 1503 | 1 | ▶ | sub getReports { | ||||||||||||||||||||||||||||||
|
Subroutine
getReports: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1504 | 1 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1505 | 1 | my ( $self, $project_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1506 | 1 | my $url = "index.php?/api/v2/get_reports/$project_id"; | |||||||||||||||||||||||||||||||
| 1507 | 1 | return $self->_doRequest( $url, 'GET' ); | |||||||||||||||||||||||||||||||
| 1508 | } | ||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||
| 1510 | 1 | ▶ | sub runReport { | ||||||||||||||||||||||||||||||
|
Subroutine
runReport: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1511 | 1 | state $check = compile( Object, Int ); | |||||||||||||||||||||||||||||||
| 1512 | 1 | my ( $self, $report_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1513 | 1 | my $url = "index.php?/api/v2/run_report/$report_id"; | |||||||||||||||||||||||||||||||
| 1514 | 1 | return $self->_doRequest( $url, 'GET' ); | |||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||
| 1517 | #Convenience method for building stepResults | ||||||||||||||||||||||||||||||||
| 1518 | 16 | ▶ | sub buildStepResults { | ||||||||||||||||||||||||||||||
|
Subroutine
buildStepResults: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 1519 | 16 | state $check = compile( Str, Str, Str, Int ); | |||||||||||||||||||||||||||||||
| 1520 | 16 | my ( $content, $expected, $actual, $status_id ) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||
| 1522 | return { | ||||||||||||||||||||||||||||||||
| 1523 | 16 | content => $content, | |||||||||||||||||||||||||||||||
| 1524 | expected => $expected, | ||||||||||||||||||||||||||||||||
| 1525 | actual => $actual, | ||||||||||||||||||||||||||||||||
| 1526 | status_id => $status_id | ||||||||||||||||||||||||||||||||
| 1527 | }; | ||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||
| 1530 | # Convenience method for building filter string from filters Hashref | ||||||||||||||||||||||||||||||||
| 1531 | 404 | ▶ | sub _convert_filters_to_string { | ||||||||||||||||||||||||||||||
|
Subroutine
_convert_filters_to_string: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||
| 1532 | 404 | state $check = compile( Maybe [HashRef] ); | |||||||||||||||||||||||||||||||
| 1533 | 404 | my ($filters) = $check->(@_); | |||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||
| 1535 | 404 | ▶ | $filters //= {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$filters //= {}
MC/DC100%1/1
$filters //= {}
$filters
Truth table100%2/2
A
A= $filters
| |||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||
| 1537 | 404 | my $filter_string = ''; | |||||||||||||||||||||||||||||||
| 1538 | 404 | foreach my $filter ( keys(%$filters) ) { | |||||||||||||||||||||||||||||||
| 1539 | 29 | ▶ | if ( ref $filters->{$filter} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1540 | $filter_string .= | ||||||||||||||||||||||||||||||||
| 1541 | 0 | "&$filter=" . join( ',', @{ $filters->{$filter} } ); | |||||||||||||||||||||||||||||||
| 1542 | } | ||||||||||||||||||||||||||||||||
| 1543 | else { | ||||||||||||||||||||||||||||||||
| 1544 | $filter_string .= "&$filter=" . $filters->{$filter} | ||||||||||||||||||||||||||||||||
| 1545 | 29 | ▶ | if defined( $filters->{$filter} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||
| 1547 | } | ||||||||||||||||||||||||||||||||
| 1548 | 404 | return $filter_string; | |||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||
| 1551 | 36 | 1; | |||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||
| 1553 | __END__ | ||||||||||||||||||||||||||||||||