Merge lp:~kfader/mvhub/pages.t-too-slow into lp:mvhub

Proposed by Keith Fader
Status: Merged
Merged at revision: 512
Proposed branch: lp:~kfader/mvhub/pages.t-too-slow
Merge into: lp:mvhub
Diff against target: 448 lines (+99/-33)
6 files modified
app-mvhub/t/bugs/admin_logout_bug.t (+2/-2)
app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t (+6/-8)
app-mvhub/t/bugs/ql_display_agency_home_interaction.t (+4/-3)
app-mvhub/t/bugs/ql_works_after_admin_login.t (+3/-3)
app-mvhub/t/mech/pages.t (+53/-17)
lib-mvhub/t/lib/TestHelper.pm (+31/-0)
To merge this branch: bzr merge lp:~kfader/mvhub/pages.t-too-slow
Reviewer Review Type Date Requested Status
Dan MacNeil Approve
Review via email: mp+37314@code.launchpad.net

Description of the change

See commit log.

To post a comment you must log in.
Revision history for this message
Dan MacNeil (omacneil) wrote :

curious as to purpose of line #49 in diff

48 + 'mech'=>'',
49 + 'http_response'=>'',

review: Needs Information
Revision history for this message
Dan MacNeil (omacneil) wrote :

A few problems:

You take out all the:

  $mech->get( $$page{url}

..so the tests are all invalid, they test a mech object that doesn't contain a page. We save a lot of time by not traveling over the network to fetch a web page, but we cant test the links or the validity of the html if we don't have the page.

perl objects are references, roughly akin to pointers.

So you assign a pointer to the same thing to each mech object in the @pages array.

if a is pointer that points to address 33558 and you say a=b then b also points to address 33558

To help see these problems paste this code into main at some point.

foreach my $page_href (@total_pages){
    my $mech=$$page_href{mech};
       print "mech object is:",$$page_href{mech}, q/$mech->title() is: '/,$mech$
}
;
exit 0;

One patial solution would be to create a new() object in your add_mech_objects() sub and to call $mech->get( $$page{url} in that sub.

review: Needs Fixing
lp:~kfader/mvhub/pages.t-too-slow updated
504. By Keith Fader

Modified these files to initialize mech objects correctly. TestHelper will now grab the mech objects out of the pages hash, for consistency.

505. By Keith Fader

Fixed add_mech_objects to initialize new mech object each time. Modified TestHelper to use cached mech objects for consistency

Revision history for this message
Dan MacNeil (omacneil) wrote :

39 + #TestHelper::pages_get_ok( $mech, @total_pages );

On general principles, you shouldn't submit commented out code for merge request.

It adds noise, With version control you can get it back

review: Needs Fixing
Revision history for this message
Dan MacNeil (omacneil) wrote :

tests fail.

Before submitting merge request, all should pass

run them with:

   mv_prove -r app-mvhub/t lib-mvhub/t

app-mvhub/t/perltidy.t fails.

...and anything that uses TestHelper::pages_get_ok()

sub routine was in a library for a reason...

Need to either add caching to routine (quick little & little ugly) or change every test file that uses it.

review: Needs Fixing
lp:~kfader/mvhub/pages.t-too-slow updated
506. By Keith Fader

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.

507. By Keith Fader

Changes from two weeks ago.

508. By Keith Fader

merged trunk

Revision history for this message
Dan MacNeil (omacneil) wrote :

in pages.t

   sub add_mech_objects {

... is never called.

review: Needs Fixing
Revision history for this message
Dan MacNeil (omacneil) wrote :

8 - my $mech = shift or die 'pages_get_ok() missing param: $mech';
9 - my @pages = @_ or die 'pages_get_ok() missing param: @pages';
10 + my $mech = shift or die 'run_tests() missing param: $mech';
11 + my @pages = @_ or die 'run_tests() missing param: @pages';

Good in passing fix, closer to perfect would be to mention in commit log

Revision history for this message
Dan MacNeil (omacneil) wrote :

Otherwise good.

Revision history for this message
Dan MacNeil (omacneil) wrote :

merge fairy will remove the kruft.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app-mvhub/t/bugs/admin_logout_bug.t'
--- app-mvhub/t/bugs/admin_logout_bug.t 2010-09-27 13:28:16 +0000
+++ app-mvhub/t/bugs/admin_logout_bug.t 2010-10-29 19:42:40 +0000
@@ -45,8 +45,8 @@
45use Test::Harness;45use Test::Harness;
4646
47sub run_tests {47sub run_tests {
48 my $mech = shift or die 'pages_get_ok() missing param: $mech';48 my $mech = shift or die 'run_tests() missing param: $mech';
49 my @pages = @_ or die 'pages_get_ok() missing param: @pages';49 my @pages = @_ or die 'run_tests() missing param: @pages';
5050
51 foreach my $page (@pages) {51 foreach my $page (@pages) {
52 $mech->add_header( Authorization => $$page{auth} )52 $mech->add_header( Authorization => $$page{auth} )
5353
=== modified file 'app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t'
--- app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t 2010-09-27 13:28:16 +0000
+++ app-mvhub/t/bugs/categorize_link_missing_when_agency_login.t 2010-10-29 19:42:40 +0000
@@ -22,11 +22,9 @@
22 my $number_of_tests = ( ( scalar @pages ) * 4 );22 my $number_of_tests = ( ( scalar @pages ) * 4 );
2323
24 plan tests => $number_of_tests;24 plan tests => $number_of_tests;
25 my $mech = Test::WWW::Mechanize->new();
26 $mech->default_header( Authorization => TestHelper::create_temp_auth() );
2725
28 TestHelper::pages_get_ok( $mech, @pages );26 TestHelper::pages_add_ok(@pages);
29 check_for_categorize_link( $mech, @pages );27 check_for_categorize_link(@pages);
30} # main28} # main
3129
32sub init_pages {30sub init_pages {
@@ -45,17 +43,17 @@
45 "Agency Account Home Page - North Shore Community Action Programs",43 "Agency Account Home Page - North Shore Community Action Programs",
46 'tests_to_skip' => '',44 'tests_to_skip' => '',
47 'todo_reason' => 'Need to fix diplay agency home page',45 'todo_reason' => 'Need to fix diplay agency home page',
46 'mech' => undef,
48 },47 },
49 );48 );
50 return @pages;49 return @pages;
51}50}
5251
53sub check_for_categorize_link {52sub check_for_categorize_link {
54 my $mech = shift or die 'page_links_ok() missing param: $mech';53 my @pages = @_ or die 'page_links_ok() missing param: @pages';
55 my @pages = @_ or die 'page_links_ok() missing param: @pages';54 my $mech;
56
57 foreach my $page (@pages) {55 foreach my $page (@pages) {
58 $mech->get( $$page{url} );56 $mech = $$page{mech};
59 ok( $mech->find_link( text => 'categorize' ),57 ok( $mech->find_link( text => 'categorize' ),
60 "Found categorize link on the page"58 "Found categorize link on the page"
61 );59 );
6260
=== modified file 'app-mvhub/t/bugs/ql_display_agency_home_interaction.t'
--- app-mvhub/t/bugs/ql_display_agency_home_interaction.t 2010-09-27 13:28:16 +0000
+++ app-mvhub/t/bugs/ql_display_agency_home_interaction.t 2010-10-29 19:42:40 +0000
@@ -22,10 +22,8 @@
22 my $number_of_tests = ( ( scalar @pages ) * 3 );22 my $number_of_tests = ( ( scalar @pages ) * 3 );
2323
24 plan tests => $number_of_tests;24 plan tests => $number_of_tests;
25 my $mech = Test::WWW::Mechanize->new();
26 $mech->default_header( Authorization => TestHelper::create_temp_auth() );
2725
28 TestHelper::pages_get_ok( $mech, @pages );26 TestHelper::pages_add_ok(@pages);
2927
30} # main28} # main
3129
@@ -44,6 +42,7 @@
44 "Agency Account Home Page - North Shore Community Action Programs",42 "Agency Account Home Page - North Shore Community Action Programs",
45 'tests_to_skip' => '',43 'tests_to_skip' => '',
46 'skip_reason' => '',44 'skip_reason' => '',
45 'mech' => undef
47 },46 },
4847
49 { 'url' =>48 { 'url' =>
@@ -51,6 +50,7 @@
51 'expected_content' => "You must log in to access this page",50 'expected_content' => "You must log in to access this page",
52 'tests_to_skip' => '',51 'tests_to_skip' => '',
53 'skip_reason' => '',52 'skip_reason' => '',
53 'mech' => undef
54 },54 },
5555
56 { 'url' =>56 { 'url' =>
@@ -58,6 +58,7 @@
58 'expected_content' => "Transitions",58 'expected_content' => "Transitions",
59 'tests_to_skip' => '',59 'tests_to_skip' => '',
60 'skip_reason' => '',60 'skip_reason' => '',
61 'mech' => undef
61 },62 },
6263
63 );64 );
6465
=== modified file 'app-mvhub/t/bugs/ql_works_after_admin_login.t'
--- app-mvhub/t/bugs/ql_works_after_admin_login.t 2010-09-13 00:58:44 +0000
+++ app-mvhub/t/bugs/ql_works_after_admin_login.t 2010-10-29 19:42:40 +0000
@@ -25,10 +25,8 @@
25 my $number_of_tests = ( ( scalar @pages ) * 3 );25 my $number_of_tests = ( ( scalar @pages ) * 3 );
2626
27 plan tests => $number_of_tests;27 plan tests => $number_of_tests;
28 my $mech = Test::WWW::Mechanize->new();
29 $mech->default_header( Authorization => TestHelper::create_temp_auth() );
3028
31 TestHelper::pages_get_ok( $mech, @pages );29 TestHelper::pages_add_ok(@pages);
32} # main30} # main
3331
34sub init_pages {32sub init_pages {
@@ -43,6 +41,7 @@
43 'expected_content' => "Welcome to the Administrative Home Page",41 'expected_content' => "Welcome to the Administrative Home Page",
44 'tests_to_skip' => '',42 'tests_to_skip' => '',
45 'skip_reason' => '',43 'skip_reason' => '',
44 'mech' => undef,
46 },45 },
47 { 'url' =>46 { 'url' =>
48 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id",47 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id",
@@ -50,6 +49,7 @@
50 "Agency Account Home Page - North Shore Community Action Programs",49 "Agency Account Home Page - North Shore Community Action Programs",
51 'tests_to_skip' => '',50 'tests_to_skip' => '',
52 'skip_reason' => '',51 'skip_reason' => '',
52 'mech' => undef,
53 },53 },
5454
55 );55 );
5656
=== modified file 'app-mvhub/t/mech/pages.t'
--- app-mvhub/t/mech/pages.t 2010-09-13 00:58:44 +0000
+++ app-mvhub/t/mech/pages.t 2010-10-29 19:42:40 +0000
@@ -14,6 +14,7 @@
1414
15{ #main15{ #main
16 my $host = TestHelper::get_test_website_name('mvh');16 my $host = TestHelper::get_test_website_name('mvh');
17 my $mech = Test::WWW::Mechanize->new();
1718
18 my @mvh_pages_from_both = init_pages_for_both($host);19 my @mvh_pages_from_both = init_pages_for_both($host);
19 my @pages_for_mvh = init_pages_for_mvh_only($host);20 my @pages_for_mvh = init_pages_for_mvh_only($host);
@@ -33,17 +34,15 @@
33 );34 );
3435
35 my $NUMBER_OF_TESTS_PER_PAGE = 6;36 my $NUMBER_OF_TESTS_PER_PAGE = 6;
37
36 my $number_of_tests38 my $number_of_tests
37 = ( ( scalar @total_pages ) * $NUMBER_OF_TESTS_PER_PAGE );39 = ( ( scalar @total_pages ) * $NUMBER_OF_TESTS_PER_PAGE );
38
39 plan tests => $number_of_tests;40 plan tests => $number_of_tests;
40 my $mech = Test::WWW::Mechanize->new();
41 $mech->default_header( Authorization => TestHelper::create_temp_auth() );
4241
43 TestHelper::pages_get_ok( $mech, @total_pages );42 TestHelper::pages_add_ok(@total_pages);
44 pages_links_ok( $mech, @total_pages );43 pages_links_ok(@total_pages);
45 pages_lint_ok( $mech, @total_pages );44 pages_lint_ok(@total_pages);
46 pages_html_tidy_ok( $mech, @total_pages );45 pages_html_tidy_ok(@total_pages);
4746
48} #main47} #main
4948
@@ -55,62 +54,74 @@
55 'expected_content' => " Search for Social Services",54 'expected_content' => " Search for Social Services",
56 'tests_to_skip' => 'tidy lint link get',55 'tests_to_skip' => 'tidy lint link get',
57 'skip_reason' => 'dan 2008-02-06 testing ability to skip',56 'skip_reason' => 'dan 2008-02-06 testing ability to skip',
57 'mech' => undef,
58 },58 },
59 { 'url' => "http://$host",59 { 'url' => "http://$host",
60 'expected_content' => "Search for Social Services",60 'expected_content' => "Search for Social Services",
61 'tests_to_skip' => '',61 'tests_to_skip' => '',
62 'skip_reason' => '',62 'skip_reason' => '',
63 'mech' => undef,
63 },64 },
64 { 'url' => "http://$host/html/about.shtml",65 { 'url' => "http://$host/html/about.shtml",
65 'expected_content' => "Our Purpose",66 'expected_content' => "Our Purpose",
66 'tests_to_skip' => '',67 'tests_to_skip' => '',
67 'skip_reason' => '',68 'skip_reason' => '',
69 'mech' => undef,
68 },70 },
69 { 'url' => "http://$host/html/help.shtml",71 { 'url' => "http://$host/html/help.shtml",
70 'expected_content' => "Agency Account Help",72 'expected_content' => "Agency Account Help",
71 'tests_to_skip' => '',73 'tests_to_skip' => '',
72 'skip_reason' => '',74 'skip_reason' => '',
75 'mech' => undef,
73 },76 },
74 { 'url' => "http://$host/html/register.shtml",77 { 'url' => "http://$host/html/register.shtml",
75 'expected_content' => "Why register your agency",78 'expected_content' => "Why register your agency",
76 'tests_to_skip' => '',79 'tests_to_skip' => '',
77 'skip_reason' => '',80 'skip_reason' => '',
81 'mech' => undef,
78 },82 },
79 { 'url' => "http://$host/reports",83 { 'url' => "http://$host/reports",
80 'expected_content' => "PDF Reports",84 'expected_content' => "PDF Reports",
81 'tests_to_skip' => '',85 'tests_to_skip' => '',
82 'skip_reason' => '',86 'skip_reason' => '',
87 'mech' => undef,
83 },88 },
84 { 'url' => "http://$host/reports/",89 { 'url' => "http://$host/reports/",
85 'expected_content' => "PDF Reports",90 'expected_content' => "PDF Reports",
86 'tests_to_skip' => '',91 'tests_to_skip' => '',
87 'skip_reason' => '',92 'skip_reason' => '',
93 'mech' => undef,
88 },94 },
8995
90 { 'url' => "http://$host/cgi-bin/mvhub/agency_form.pl",96 { 'url' => "http://$host/cgi-bin/mvhub/agency_form.pl",
91 'expected_content' => "Password",97 'expected_content' => "Password",
92 'tests_to_skip' => '',98 'tests_to_skip' => '',
93 'skip_reason' => '',99 'skip_reason' => '',
100 'mech' => undef,
94 },101 },
95 { 'url' => "http://$host/cgi-bin/mvhub/guide.pl?rm=browse_headings",102 { 'url' => "http://$host/cgi-bin/mvhub/guide.pl?rm=browse_headings",
96 'expected_content' => "Arts/Culture/Entertainment",103 'expected_content' => "Arts/Culture/Entertainment",
97 'tests_to_skip' => '',104 'tests_to_skip' => '',
98 'skip_reason' => '',105 'skip_reason' => '',
106 'mech' => undef,
99 },107 },
100 { 'url' => "http://$host/cgi-bin/mvhub/admin/admin_reports.pl",108 { 'url' => "http://$host/cgi-bin/mvhub/admin/admin_reports.pl",
101 'expected_content' => "Administrative Reports",109 'expected_content' => "Administrative Reports",
102 'tests_to_skip' => '',110 'tests_to_skip' => '',
103 'skip_reason' => '',111 'skip_reason' => '',
112 'mech' => undef,
104 },113 },
105 { 'url' => "http://$host/cgi-bin/mvhub/admin/admin.pl",114 { 'url' => "http://$host/cgi-bin/mvhub/admin/admin.pl",
106 'expected_content' => "Add a New Agency",115 'expected_content' => "Add a New Agency",
107 'tests_to_skip' => '',116 'tests_to_skip' => '',
108 'skip_reason' => '',117 'skip_reason' => '',
118 'mech' => undef,
109 },119 },
110 { 'url' => "http://$host/cgi-bin/mvhub/logout.pl",120 { 'url' => "http://$host/cgi-bin/mvhub/logout.pl",
111 'expected_content' => "You have been logged out",121 'expected_content' => "You have been logged out",
112 'tests_to_skip' => '',122 'tests_to_skip' => '',
113 'skip_reason' => '',123 'skip_reason' => '',
124 'mech' => undef,
114 },125 },
115 { 'url' =>126 { 'url' =>
116 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=00&qlid=00",127 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=00&qlid=00",
@@ -118,12 +129,14 @@
118 "Invalid quick log-in ID, please log in manually",129 "Invalid quick log-in ID, please log in manually",
119 'tests_to_skip' => '',130 'tests_to_skip' => '',
120 'skip_reason' => '',131 'skip_reason' => '',
132 'mech' => undef,
121 },133 },
122 { 'url' => "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=00",134 { 'url' => "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&id=00",
123 'expected_content' =>135 'expected_content' =>
124 "You used an old login URL that is no longer valid",136 "You used an old login URL that is no longer valid",
125 'tests_to_skip' => '',137 'tests_to_skip' => '',
126 'skip_reason' => '',138 'skip_reason' => '',
139 'mech' => undef,
127 },140 },
128 );141 );
129 return @pages;142 return @pages;
@@ -139,6 +152,7 @@
139 'expected_content' => "You must log in to access this page",152 'expected_content' => "You must log in to access this page",
140 'tests_to_skip' => '',153 'tests_to_skip' => '',
141 'skip_reason' => '',154 'skip_reason' => '',
155 'mech' => undef,
142 },156 },
143 { 'url' =>157 { 'url' =>
144 "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=100088",158 "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=100088",
@@ -146,23 +160,27 @@
146 'tests_to_skip' => 'tidy lint',160 'tests_to_skip' => 'tidy lint',
147 'skip_reason' =>161 'skip_reason' =>
148 'dan 2008-02-06 record uses smart quotes we dont strip ',162 'dan 2008-02-06 record uses smart quotes we dont strip ',
163 'mech' => undef,
149 },164 },
150 { 'url' =>165 { 'url' =>
151 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=101342",166 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=101342",
152 'expected_content' => "(The CSL)",167 'expected_content' => "(The CSL)",
153 'tests_to_skip' => '',168 'tests_to_skip' => '',
154 'skip_reason' => '',169 'skip_reason' => '',
170 'mech' => undef,
155 },171 },
156 { 'url' =>172 { 'url' =>
157 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=503916",173 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=503916",
158 'expected_content' => "Community Software Lab",174 'expected_content' => "Community Software Lab",
159 'tests_to_skip' => '',175 'tests_to_skip' => '',
160 'skip_reason' => '',176 'skip_reason' => '',
177 'mech' => undef,
161 },178 },
162 { 'url' => "http://$host/html/reports.shtml",179 { 'url' => "http://$host/html/reports.shtml",
163 'expected_content' => "formatted for printing",180 'expected_content' => "formatted for printing",
164 'tests_to_skip' => 'link',181 'tests_to_skip' => 'link',
165 'skip_reason' => 'dan 2008-02-06 link to pdf not implemented',182 'skip_reason' => 'dan 2008-02-06 link to pdf not implemented',
183 'mech' => undef,
166 },184 },
167 { 'url' =>185 { 'url' =>
168 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=804796",186 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=804796",
@@ -170,6 +188,7 @@
170 "programs related to: Visual Arts Classes, Youth/Teen",188 "programs related to: Visual Arts Classes, Youth/Teen",
171 'tests_to_skip' => '',189 'tests_to_skip' => '',
172 'skip_reason' => '',190 'skip_reason' => '',
191 'mech' => undef,
173 },192 },
174 );193 );
175}194}
@@ -189,6 +208,7 @@
189 'expected_content' => "You must log in to access this page",208 'expected_content' => "You must log in to access this page",
190 'tests_to_skip' => '',209 'tests_to_skip' => '',
191 'skip_reason' => '',210 'skip_reason' => '',
211 'mech' => undef,
192 },212 },
193 { 'url' =>213 { 'url' =>
194 "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103531",214 "http://$host//cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103531",
@@ -196,18 +216,21 @@
196 'tests_to_skip' => 'tidy lint',216 'tests_to_skip' => 'tidy lint',
197 'skip_reason' =>217 'skip_reason' =>
198 'dan 2008-02-06 record uses smart quotes we dont strip ',218 'dan 2008-02-06 record uses smart quotes we dont strip ',
219 'mech' => undef,
199 },220 },
200 { 'url' =>221 { 'url' =>
201 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103542",222 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_agency&agency_id=103542",
202 'expected_content' => "Law Center of Massachusetts",223 'expected_content' => "Law Center of Massachusetts",
203 'tests_to_skip' => '',224 'tests_to_skip' => '',
204 'skip_reason' => '',225 'skip_reason' => '',
226 'mech' => undef,
205 },227 },
206 { 'url' =>228 { 'url' =>
207 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=509515",229 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program&program_id=509515",
208 'expected_content' => "(NSCAP)",230 'expected_content' => "(NSCAP)",
209 'tests_to_skip' => '',231 'tests_to_skip' => '',
210 'skip_reason' => '',232 'skip_reason' => '',
233 'mech' => undef,
211 },234 },
212 { 'url' =>235 { 'url' =>
213 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=801584",236 "http://$host/cgi-bin/mvhub/guide.pl?rm=show_program_results&category_id=801584",
@@ -215,12 +238,14 @@
215 "programs related to: Adult Basic Education",238 "programs related to: Adult Basic Education",
216 'tests_to_skip' => '',239 'tests_to_skip' => '',
217 'skip_reason' => '',240 'skip_reason' => '',
241 'mech' => undef,
218 },242 },
219 { 'url' => "http://$host/$agency_id/$quick_login_id",243 { 'url' => "http://$host/$agency_id/$quick_login_id",
220 'expected_content' =>244 'expected_content' =>
221 "Agency Account Home Page - North Shore Community Action Programs, Inc.",245 "Agency Account Home Page - North Shore Community Action Programs, Inc.",
222 'tests_to_skip' => '',246 'tests_to_skip' => '',
223 'skip_reason' => '',247 'skip_reason' => '',
248 'mech' => undef,
224 },249 },
225 { 'url' =>250 { 'url' =>
226 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id",251 "http://$host/cgi-bin/mvhub/agency.pl?rm=ql&aid=$agency_id&qlid=$quick_login_id",
@@ -228,18 +253,31 @@
228 "Agency Account Home Page - North Shore Community Action Programs, Inc.",253 "Agency Account Home Page - North Shore Community Action Programs, Inc.",
229 'tests_to_skip' => '',254 'tests_to_skip' => '',
230 'skip_reason' => '',255 'skip_reason' => '',
256 'mech' => undef,
231 },257 },
232 );258 );
233}259}
234260
261sub add_mech_objects {
262 my @pages = @_ or die 'add_mech_objects() missing param: @pages';
263
264 foreach my $page (@pages) {
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 }
271 @pages;
272}
273
235sub pages_links_ok {274sub pages_links_ok {
236 my $mech = shift or die 'page_links_ok() missing param: $mech';275 my @pages = @_ or die 'page_links_ok() missing param: @pages';
237 my @pages = @_ or die 'page_links_ok() missing param: @pages';276 my $mech = '';
238
239PAGES:277PAGES:
240 foreach my $page (@pages) {278 foreach my $page (@pages) {
241 SKIP: {279 SKIP: {
242 $mech->get( $$page{url} );280 $mech = $$page{mech};
243 if ( $$page{tests_to_skip} =~ 'link' ) {281 if ( $$page{tests_to_skip} =~ 'link' ) {
244 skip "$$page{url} $$page{skip_reason}", 1;282 skip "$$page{url} $$page{skip_reason}", 1;
245 next PAGES;283 next PAGES;
@@ -296,12 +334,11 @@
296}334}
297335
298sub pages_lint_ok {336sub pages_lint_ok {
299 my $mech = shift or die 'page_lint_ok() missing param: $mech';337 my @pages = @_ or die 'page_lint_ok() missing param: @pages';
300 my @pages = @_ or die 'page_lint_ok() missing param: @pages';
301338
302 foreach my $page (@pages) {339 foreach my $page (@pages) {
303 SKIP: {340 SKIP: {
304 $mech->get( $$page{url} );341 my $mech = $$page{mech};
305 skip $$page{skip_reason}, 1342 skip $$page{skip_reason}, 1
306 if $$page{tests_to_skip} =~ 'lint';343 if $$page{tests_to_skip} =~ 'lint';
307 $mech->html_lint_ok("Lint: ");344 $mech->html_lint_ok("Lint: ");
@@ -310,12 +347,11 @@
310}347}
311348
312sub pages_html_tidy_ok {349sub pages_html_tidy_ok {
313 my $mech = shift or die 'pages_html_tidy_ok() missing param: $mech';350 my @pages = @_ or die 'pages_html_tidy_ok() missing param: @pages';
314 my @pages = @_ or die 'pages_html_tidy_ok() missing param: @pages';
315351
316 foreach my $page (@pages) {352 foreach my $page (@pages) {
317 SKIP: {353 SKIP: {
318 $mech->get( $$page{url} );354 my $mech = $$page{mech};
319 skip $$page{skip_reason}, 1355 skip $$page{skip_reason}, 1
320 if $$page{tests_to_skip} =~ 'tidy';356 if $$page{tests_to_skip} =~ 'tidy';
321 my $short_page = shorten_pagename( $$page{url} );357 my $short_page = shorten_pagename( $$page{url} );
322358
=== modified file 'lib-mvhub/t/lib/TestHelper.pm'
--- lib-mvhub/t/lib/TestHelper.pm 2010-10-16 00:29:43 +0000
+++ lib-mvhub/t/lib/TestHelper.pm 2010-10-29 19:42:40 +0000
@@ -189,6 +189,37 @@
189 }189 }
190}190}
191191
192sub pages_add_ok {
193 my @pages = @_ or die 'pages_add_ok() missing param: @pages';
194 my $mech;
195
196 foreach my $page (@pages) {
197 SKIP: {
198 skip "$page->{url} $$page{skip_reason}", 3
199 if $$page{tests_to_skip} =~ 'get';
200
201 if ( not defined $$page{mech} ) {
202 $$page{mech} = Test::WWW::Mechanize->new();
203 $$page{mech}->default_header(
204 Authorization => TestHelper::create_temp_auth() );
205 }
206
207 $mech = $$page{mech};
208 $mech->get_ok( $$page{url}, "got ok: $$page{url}" );
209 $mech->content_lacks(
210 'an error in processing your request',
211 "no error in:
212 " . $page->{url}
213 );
214 $mech->content_contains(
215 $$page{expected_content},
216 " $$page{expected_content}
217 found in: $page->{url}"
218 );
219 }
220 }
221}
222
192sub run_submit_forms_ok {223sub run_submit_forms_ok {
193 my %args = @_;224 my %args = @_;
194 my $prefix = $args{prefix} or croak "missing param: \$prefix";225 my $prefix = $args{prefix} or croak "missing param: \$prefix";

Subscribers

People subscribed via source and target branches