~kfader/mvhub/pages.t-too-slow

« back to all changes in this revision

Viewing changes to app-mvhub/t/mech/pages.t

  • Committer: Keith Fader
  • Date: 2010-10-15 18:36:58 UTC
  • Revision ID: kfader@thecsl.org-20101015183658-47npdd88et8gv8v3
Reverted TestHelper.pm. There was no need to change it in the first 
place. Ran perltidy on pages.t. All tests pass, speed is good.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    my $host = TestHelper::get_test_website_name('mvh');
17
17
    my $mech = Test::WWW::Mechanize->new();
18
18
 
19
 
 
20
19
    my @mvh_pages_from_both = init_pages_for_both($host);
21
20
    my @pages_for_mvh       = init_pages_for_mvh_only($host);
22
21
 
29
28
    my @pages_for_nsp
30
29
        = init_pages_for_nsp_only( $host, $agency_id, $quick_login_id );
31
30
 
32
 
    my @total_pages = add_mech_objects( @mvh_pages_from_both, @pages_for_mvh,
33
 
                                        @nsp_pages_from_both, @pages_for_nsp);
 
31
    my @total_pages = add_mech_objects(
 
32
        @mvh_pages_from_both, @pages_for_mvh,
 
33
        @nsp_pages_from_both, @pages_for_nsp
 
34
    );
34
35
 
35
36
    my $NUMBER_OF_TESTS_PER_PAGE = 6;
36
37
 
37
 
    my $number_of_tests  = ( ( scalar @total_pages ) * $NUMBER_OF_TESTS_PER_PAGE );
 
38
    my $number_of_tests
 
39
        = ( ( scalar @total_pages ) * $NUMBER_OF_TESTS_PER_PAGE );
38
40
    plan tests => $number_of_tests;
39
41
 
40
 
   #TestHelper::pages_get_ok( $mech, @total_pages );
41
 
    TestHelper::pages_get_ok(@total_pages);
42
 
    pages_links_ok(@total_pages );
43
 
    pages_lint_ok(@total_pages );
44
 
    pages_html_tidy_ok(@total_pages );
45
 
 
 
42
    TestHelper::pages_get_ok( $mech, @total_pages );
 
43
    pages_links_ok(@total_pages);
 
44
    pages_lint_ok(@total_pages);
 
45
    pages_html_tidy_ok(@total_pages);
 
46
 
46
47
}    #main
47
48
 
48
49
sub init_pages_for_both {
53
54
            'expected_content' => " Search for Social Services",
54
55
            'tests_to_skip'    => 'tidy lint link get',
55
56
            'skip_reason'      => 'dan 2008-02-06 testing ability to skip',
56
 
            'mech'=>'',
 
57
            'mech'             => '',
57
58
        },
58
59
        {   'url'              => "http://$host",
59
60
            'expected_content' => "Search for Social Services",
60
61
            'tests_to_skip'    => '',
61
62
            'skip_reason'      => '',
62
 
            'mech'=>'',
 
63
            'mech'             => '',
63
64
        },
64
65
        {   'url'              => "http://$host/html/about.shtml",
65
66
            'expected_content' => "Our Purpose",
66
67
            'tests_to_skip'    => '',
67
68
            'skip_reason'      => '',
68
 
            'mech'=>'',
 
69
            'mech'             => '',
69
70
        },
70
71
        {   'url'              => "http://$host/html/help.shtml",
71
72
            'expected_content' => "Agency Account Help",
72
73
            'tests_to_skip'    => '',
73
74
            'skip_reason'      => '',
74
 
            'mech'=>'',
 
75
            'mech'             => '',
75
76
        },
76
77
        {   'url'              => "http://$host/html/register.shtml",
77
78
            'expected_content' => "Why register your agency",
78
79
            'tests_to_skip'    => '',
79
80
            'skip_reason'      => '',
80
 
            'mech'=>'',
 
81
            'mech'             => '',
81
82
        },
82
83
        {   'url'              => "http://$host/reports",
83
84
            'expected_content' => "PDF Reports",
84
85
            'tests_to_skip'    => '',
85
86
            'skip_reason'      => '',
86
 
            'mech'=>'',
 
87
            'mech'             => '',
87
88
        },
88
89
        {   'url'              => "http://$host/reports/",
89
90
            'expected_content' => "PDF Reports",
90
91
            'tests_to_skip'    => '',
91
92
            'skip_reason'      => '',
92
 
            'mech'=>'',
 
93
            'mech'             => '',
93
94
        },
94
95
 
95
96
        {   'url'              => "http://$host/cgi-bin/mvhub/agency_form.pl",
96
97
            'expected_content' => "Password",
97
98
            'tests_to_skip'    => '',
98
99
            'skip_reason'      => '',
99
 
            'mech'=>'',
 
100
            'mech'             => '',
100
101
        },
101
102
        {   'url' => "http://$host/cgi-bin/mvhub/guide.pl?rm=browse_headings",
102
103
            'expected_content' => "Arts/Culture/Entertainment",
103
104
            'tests_to_skip'    => '',
104
105
            'skip_reason'      => '',
105
 
            'mech'=>'',
 
106
            'mech'             => '',
106
107
        },
107
108
        {   'url' => "http://$host/cgi-bin/mvhub/admin/admin_reports.pl",
108
109
            'expected_content' => "Administrative Reports",
109
110
            'tests_to_skip'    => '',
110
111
            'skip_reason'      => '',
111
 
            'mech'=>'',
 
112
            'mech'             => '',
112
113
        },
113
114
        {   'url'              => "http://$host/cgi-bin/mvhub/admin/admin.pl",
114
115
            'expected_content' => "Add a New Agency",
115
116
            'tests_to_skip'    => '',
116
117
            'skip_reason'      => '',
117
 
            'mech'=>'',
 
118
            'mech'             => '',
118
119
        },
119
120
        {   'url'              => "http://$host/cgi-bin/mvhub/logout.pl",
120
121
            'expected_content' => "You have been logged out",
121
122
            'tests_to_skip'    => '',
122
123
            'skip_reason'      => '',
123
 
            'mech'=>'',
 
124
            'mech'             => '',
124
125
        },
125
126
        {   'url' =>
126
127
                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=00&qlid=00",
128
129
                "Invalid quick log-in ID, please log in manually",
129
130
            'tests_to_skip' => '',
130
131
            'skip_reason'   => '',
131
 
            'mech'=>'',
 
132
            'mech'          => '',
132
133
        },
133
134
        {   'url' => "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=00",
134
135
            'expected_content' =>
135
136
                "You used an old login URL that is no longer valid",
136
137
            'tests_to_skip' => '',
137
138
            'skip_reason'   => '',
138
 
            'mech'=>'',
 
139
            'mech'          => '',
139
140
        },
140
141
    );
141
142
    return @pages;
151
152
            'expected_content' => "You must log in to access this page",
152
153
            'tests_to_skip'    => '',
153
154
            'skip_reason'      => '',
154
 
            'mech'=>'',
 
155
            'mech'             => '',
155
156
        },
156
157
        {   'url' =>
157
158
                "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=100088",
159
160
            'tests_to_skip'    => 'tidy lint',
160
161
            'skip_reason' =>
161
162
                'dan 2008-02-06 record uses smart quotes we dont strip ',
162
 
            'mech'=>'',
 
163
            'mech' => '',
163
164
        },
164
165
        {   'url' =>
165
166
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=101342",
166
167
            'expected_content' => "(The CSL)",
167
168
            'tests_to_skip'    => '',
168
169
            'skip_reason'      => '',
169
 
            'mech'=>'',
 
170
            'mech'             => '',
170
171
        },
171
172
        {   'url' =>
172
173
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=503916",
173
174
            'expected_content' => "Community Software Lab",
174
175
            'tests_to_skip'    => '',
175
176
            'skip_reason'      => '',
176
 
            'mech'=>'',
 
177
            'mech'             => '',
177
178
        },
178
179
        {   'url'              => "http://$host/html/reports.shtml",
179
180
            'expected_content' => "formatted for printing",
180
181
            'tests_to_skip'    => 'link',
181
182
            'skip_reason' => 'dan 2008-02-06 link to pdf not implemented',
182
 
            'mech'=>'',
 
183
            'mech'        => '',
183
184
        },
184
185
        {   'url' =>
185
186
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=804796",
187
188
                "programs related to: Visual Arts Classes, Youth/Teen",
188
189
            'tests_to_skip' => '',
189
190
            'skip_reason'   => '',
190
 
            'mech'=>'',
 
191
            'mech'          => '',
191
192
        },
192
193
    );
193
194
}
207
208
            'expected_content' => "You must log in to access this page",
208
209
            'tests_to_skip'    => '',
209
210
            'skip_reason'      => '',
210
 
            'mech'=>'',
 
211
            'mech'             => '',
211
212
        },
212
213
        {   'url' =>
213
214
                "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103531",
215
216
            'tests_to_skip'    => 'tidy lint',
216
217
            'skip_reason' =>
217
218
                'dan 2008-02-06 record uses smart quotes we dont strip ',
218
 
            'mech'=>'',
 
219
            'mech' => '',
219
220
        },
220
221
        {   'url' =>
221
222
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103542",
222
223
            'expected_content' => "Law Center of Massachusetts",
223
224
            'tests_to_skip'    => '',
224
225
            'skip_reason'      => '',
225
 
            'mech'=>'',
 
226
            'mech'             => '',
226
227
        },
227
228
        {   'url' =>
228
229
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=509515",
229
230
            'expected_content' => "(NSCAP)",
230
231
            'tests_to_skip'    => '',
231
232
            'skip_reason'      => '',
232
 
            'mech'=>'',
 
233
            'mech'             => '',
233
234
        },
234
235
        {   'url' =>
235
236
                "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=801584",
237
238
                "programs related to: Adult Basic Education",
238
239
            'tests_to_skip' => '',
239
240
            'skip_reason'   => '',
240
 
            'mech'=>'',
 
241
            'mech'          => '',
241
242
        },
242
243
        {   'url' => "http://$host/$agency_id/$quick_login_id",
243
244
            'expected_content' =>
244
245
                "Agency Account Home Page - North Shore Community Action Programs, Inc.",
245
246
            'tests_to_skip' => '',
246
247
            'skip_reason'   => '',
247
 
            'mech'=>'',
 
248
            'mech'          => '',
248
249
        },
249
250
        {   'url' =>
250
251
                "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id",
252
253
                "Agency Account Home Page - North Shore Community Action Programs, Inc.",
253
254
            'tests_to_skip' => '',
254
255
            'skip_reason'   => '',
255
 
            'mech'=>'',
 
256
            'mech'          => '',
256
257
        },
257
258
    );
258
259
}
259
260
 
260
 
 
261
 
#This will populate the mech field in the hashes
262
261
sub add_mech_objects {
263
 
    my @pages=@_ or die 'add_mech_objects() missing param: @pages';
 
262
    my @pages = @_ or die 'add_mech_objects() missing param: @pages';
264
263
 
265
264
    foreach my $page (@pages) {
266
 
        my $mech=Test::WWW::Mechanize->new();
267
 
        $mech->default_header( Authorization => TestHelper::create_temp_auth() );
268
 
        $mech->get($$page{url});
269
 
        $$page{mech}=$mech;
 
265
        my $mech = Test::WWW::Mechanize->new();
 
266
        $mech->default_header(
 
267
            Authorization => TestHelper::create_temp_auth() );
 
268
        $mech->get( $$page{url} );
 
269
        $$page{mech} = $mech;
270
270
    }
271
271
    @pages;
272
272
}
273
273
 
274
274
sub pages_links_ok {
275
 
    my @pages = @_    or die 'page_links_ok() missing param: @pages';
 
275
    my @pages = @_ or die 'page_links_ok() missing param: @pages';
276
276
    my $mech = '';
277
277
PAGES:
278
278
    foreach my $page (@pages) {
279
279
    SKIP: {
280
 
            $mech=$$page{mech};
 
280
            $mech = $$page{mech};
281
281
            if ( $$page{tests_to_skip} =~ 'link' ) {
282
282
                skip "$$page{url} $$page{skip_reason}", 1;
283
283
                next PAGES;
334
334
}
335
335
 
336
336
sub pages_lint_ok {
337
 
    my @pages = @_    or die 'page_lint_ok() missing param: @pages';
 
337
    my @pages = @_ or die 'page_lint_ok() missing param: @pages';
338
338
 
339
339
    foreach my $page (@pages) {
340
340
    SKIP: {
341
 
            my $mech=$$page{mech};
 
341
            my $mech = $$page{mech};
342
342
            skip $$page{skip_reason}, 1
343
343
                if $$page{tests_to_skip} =~ 'lint';
344
344
            $mech->html_lint_ok("Lint: ");
347
347
}
348
348
 
349
349
sub pages_html_tidy_ok {
350
 
    my @pages = @_    or die 'pages_html_tidy_ok() missing param: @pages';
 
350
    my @pages = @_ or die 'pages_html_tidy_ok() missing param: @pages';
351
351
 
352
352
    foreach my $page (@pages) {
353
353
    SKIP: {
354
 
            my $mech=$$page{mech};
 
354
            my $mech = $$page{mech};
355
355
            skip $$page{skip_reason}, 1
356
356
                if $$page{tests_to_skip} =~ 'tidy';
357
357
            my $short_page = shorten_pagename( $$page{url} );