|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package RapidApp::Test;  | 
| 
2
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
2511000
 | 
 use base 'Catalyst::Test';  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1773
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
4
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
128582
 | 
 use strict;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
    | 
| 
5
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
17
 | 
 use warnings;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
89
 | 
    | 
| 
6
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
2241
 | 
 use Import::Into;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1663
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
113
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
467
 | 
 use Time::HiRes qw(gettimeofday tv_interval);  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1211
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
    | 
| 
9
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
2124
 | 
 use HTTP::Request::Common;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7322
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
274
 | 
    | 
| 
10
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
2828
 | 
 use JSON qw(decode_json);  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29078
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
    | 
| 
11
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
485
 | 
 use Catalyst::Utils;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
84
 | 
    | 
| 
12
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
1484
 | 
 use RapidApp::Test::Client;  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
509
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my $target;  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my $app_class;  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub import {  | 
| 
18
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
40
 | 
   $target = caller;  | 
| 
19
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
   my ($self, $class, @args) = @_;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # Since apps might take a while to start-up:  | 
| 
22
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
   pass("[RapidApp::Test]: loading testapp '$class'...");  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
24
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2047
 | 
   my $start = [gettimeofday];  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
26
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
   require_ok($class);  | 
| 
27
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3621
 | 
   Catalyst::Test->import::into($target,$class,@args);  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   my @funcs = grep {   | 
| 
30
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
4499
 | 
     $_ ne 'import' && $_ ne 'AUTOLOAD'  | 
| 
 
 | 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4671
 | 
    | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   } Class::MOP::Class->initialize(__PACKAGE__)->get_method_list;  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # Manually export our functions:  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   {  | 
| 
35
 | 
4
 | 
 
 | 
 
 | 
  
4
  
 | 
 
 | 
32
 | 
     no strict 'refs';  | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1687
 | 
    | 
| 
 
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
36
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
     *{ join('::',$target,$_) } = \*{ $_ } for (@funcs);  | 
| 
 
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
81
 | 
    | 
| 
 
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
    | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   ok(  | 
| 
40
 | 
4
 | 
 
 | 
  
 66
  
 | 
 
 | 
 
 | 
25
 | 
     $class->setup_finished || $class->setup,  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     sprintf("$class loaded/started (%0.4f seconds)",tv_interval($start))  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
44
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36664
 | 
   $app_class = $class;  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 };  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $AUTOLOAD;  | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub AUTOLOAD {  | 
| 
49
 | 
82
 | 
 
 | 
 
 | 
  
82
  
 | 
 
 | 
1896
 | 
   my $method = (reverse(split('::',$AUTOLOAD)))[0];  | 
| 
50
 | 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
786
 | 
   $target->can($method)->(@_);  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ## Setup the "client" object  | 
| 
54
 | 
88
 | 
 
 | 
 
 | 
  
88
  
 | 
  
0
  
 | 
17673
 | 
 my $Client; sub client { $Client }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 $Client = RapidApp::Test::Client->new({ request_caller => sub {   | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   my $req = shift;  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   ok(  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $res = client->record_response( request($req) ),  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     client->describe_request  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   return $res;  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }});  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 ##  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
  
0
  
 | 
157
 | 
 sub app_class   { $app_class }  | 
| 
66
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
0
  
 | 
12
 | 
 sub app_version { eval(join('','$',app_class(),'::VERSION')) }  | 
| 
67
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
  
0
  
 | 
0
 | 
 sub app_prefix  { Catalyst::Utils::appprefix(app_class()) }  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # These are tests which should pass for all RapidApp applications:  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # TODO: refactor into Test::Client  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub run_common_tests {  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
73
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
  
0
  
 | 
539
 | 
   ok($RapidApp::VERSION, 'RapidApp $VERSION ('.$RapidApp::VERSION.')');  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
75
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1594
 | 
   my $ver = app_version;  | 
| 
76
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
   ok($ver, 'App (' . app_class(). ') $VERSION ('.$ver.')');  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
826
 | 
   action_ok(  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     '/assets/rapidapp/misc/static/images/rapidapp_powered_logo_tiny.png',  | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     "Fetched RapidApp logo from the Misc asset controller"  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
83
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4393
 | 
   action_ok(  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     '/any/prefix/path/_ra-rel-mnt_/assets/rapidapp/misc/static/images/rapidapp_powered_logo_tiny.png',  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     "Fetched RapidApp logo from the Misc asset controller (via _ra-rel-mnt_)"  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
88
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4303
 | 
   action_notfound(  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     '/assets/rapidapp/misc/static/some/bad/file.txt',  | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     "Invalid asset path not found as expected"  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     | 
| 
93
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1445
 | 
   action_notfound(  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     '/any/prefix/path/_ra-rel-mnt_/assets/rapidapp/misc/static/some/bad/file.txt',  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     "Invalid asset path not found as expected (via _ra-rel-mnt_)"  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   );  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |