Branch Coverage

blib/lib/Tesla/API.pm
Criterion Covered Total %
branch 93 114 81.5


line true false branch
65 24 4 if ($params{'unauthenticated'})
84 1 6 unless (defined $endpoint_name)
94 1 5 if ($uri =~ /\{/)
95 1 0 unless (defined $id and $id =~ /^\d+$/)
105 5 0 if ($self->api_cache_persist or $self->api_cache_time)
107 2 3 if ($cache)
108 2 0 if ($self->api_cache_persist or time - $cache->{'time'} <= $self->api_cache_time)
119 3 0 if ($auth)
134 0 3 if ($data->{'error'})
152 3 14 if (defined $persist)
159 10 10 if (defined $cache_seconds)
160 5 5 unless ($cache_seconds =~ /^\d+$/)
170 30 15 if (not $self->{'endpoints'} or $self->{'reset_endpoints_data'})
176 0 30 unless open my $fh, "<", "/root/.cpan/build/Tesla-API-1.01-0/blib/lib/auto/share/dist/Tesla-API/endpoints.json"
185 6 39 if ($endpoint)
186 0 6 unless (exists $self->{'endpoints'}{$endpoint})
197 4 6 if ($self->{'mech'} and not $self->{'mech_reset'})
216 3 1162 if (not $self->{'option_codes'} or $self->{'reset_option_codes_data'})
223 0 3 unless open my $fh, "<", "/root/.cpan/build/Tesla-API-1.01-0/blib/lib/auto/share/dist/Tesla-API/option_codes.json"
233 1157 8 if ($code)
234 1 1156 unless (exists $self->{'option_codes'}{$code})
247 5 0 if (defined $url_type) { }
248 3 2 if $url_type eq "endpoints"
249 2 3 if $url_type eq "option_codes"
258 5 0 if ($data_url =~ m[.*/(\w+\.json)$])
262 0 5 unless (defined $filename)
278 2 3 if (scalar keys %$new_data != scalar keys %$existing_data)
282 3 2 unless ($data_differs)
284 1 1058 unless (exists $existing_data->{$key})
291 3 2 if ($data_differs)
293 2 1 $filename =~ /endpoints/ ? :
297 2 1 if ($filename =~ /endpoints/) { }
307 0 3 unless copy($file, $backup)
311 0 3 unless open my $fh, ">", "$file"
321 1 7 if (defined $ua_string)
331 14 7 if (defined $timeout)
332 9 5 unless ($timeout =~ /^\d+?(?:\.\d+)?$/)
350 0 0 unless (-e $self->_authentication_cache_file)
354 0 0 unless ($self->_access_token_valid)
367 3 6 if defined $data
369 7 2 if $self->{'cache_data'}
373 1 1 unless open my $fh, "<", $self->_authentication_cache_file
427 1 1 if (time + 5 < $token_expires_at)
439 0 5 if (not defined $token_data or ref $token_data ne "HASH")
491 0 2 if (not defined $token_data or ref $token_data ne "HASH")
497 0 2 unless open my $fh, ">", $self->_authentication_cache_file
506 12 4 if (defined $add)
507 9 3 if ($add) { }
525 1 13 unless ($endpoint)
529 6 7 if ($data)
543 4 7 if (defined $filename)
557 2 1 if $self->{'authentication_code'}
566 1 0 if ($ENV{'TESLA_API_TESTING'}) { }
591 2 1 if ($code_url =~ /code=(.*?)\&/) { }
632 2 4 if (defined $self->{'authentication_code_verifier'})
671 1 3 if ($response->is_success)
680 1 1 unless ($response->is_success)