r27320 - in /branches/upstream/libtest-www-mechanize-perl/current: Changes MANIFEST META.yml Makefile.PL Mechanize.pm t/._stuff_inputs.html t/._stuff_inputs.t t/head_ok-parms.t t/head_ok.t t/put_ok.t
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Wed Nov 26 21:36:02 UTC 2008
Author: ansgar-guest
Date: Wed Nov 26 21:35:58 2008
New Revision: 27320
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27320
Log:
[svn-upgrade] Integrating new upstream version, libtest-www-mechanize-perl (1.22)
Added:
branches/upstream/libtest-www-mechanize-perl/current/t/head_ok-parms.t
branches/upstream/libtest-www-mechanize-perl/current/t/head_ok.t
branches/upstream/libtest-www-mechanize-perl/current/t/put_ok.t
Removed:
branches/upstream/libtest-www-mechanize-perl/current/t/._stuff_inputs.html
branches/upstream/libtest-www-mechanize-perl/current/t/._stuff_inputs.t
Modified:
branches/upstream/libtest-www-mechanize-perl/current/Changes
branches/upstream/libtest-www-mechanize-perl/current/MANIFEST
branches/upstream/libtest-www-mechanize-perl/current/META.yml
branches/upstream/libtest-www-mechanize-perl/current/Makefile.PL
branches/upstream/libtest-www-mechanize-perl/current/Mechanize.pm
Modified: branches/upstream/libtest-www-mechanize-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/Changes?rev=27320&op=diff
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/Changes (original)
+++ branches/upstream/libtest-www-mechanize-perl/current/Changes Wed Nov 26 21:35:58 2008
@@ -4,8 +4,15 @@
bug tracking. They are now being tracked via Google Code at
http://code.google.com/p/www-mechanize/issues/list
+1.22 Fri Nov 21 20:29:30 CST 2008
+------------------------------------
+[ENHANCEMENTS]
+Added $mech->head_ok() and $mech->put_ok() methods. Thanks to
+Jaldhar Vyas.
+
+
1.20 Wed Mar 12 23:56:11 CDT 2008
------------------------------------
+------------------------------------
[FIXES]
stuff_inputs() used to do nothing. Now it works.
http://code.google.com/p/www-mechanize/issues/detail?id=9
Modified: branches/upstream/libtest-www-mechanize-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/MANIFEST?rev=27320&op=diff
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/MANIFEST (original)
+++ branches/upstream/libtest-www-mechanize-perl/current/MANIFEST Wed Nov 26 21:35:58 2008
@@ -13,6 +13,8 @@
t/get_ok.t
t/get_ok-parms.t
t/has_tag.t
+t/head_ok.t
+t/head_ok-parms.t
t/html_lint_ok.t
t/link_content.t
t/links_ok.t
@@ -22,6 +24,7 @@
t/page_links_ok.t
t/pod-coverage.t
t/pod.t
+t/put_ok.t
t/stuff_inputs.html
t/stuff_inputs.t
t/submit_form_ok.t
Modified: branches/upstream/libtest-www-mechanize-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/META.yml?rev=27320&op=diff
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/META.yml (original)
+++ branches/upstream/libtest-www-mechanize-perl/current/META.yml Wed Nov 26 21:35:58 2008
@@ -1,23 +1,21 @@
--- #YAML:1.0
name: Test-WWW-Mechanize
-version: 1.20
+version: 1.22
abstract: Testing-specific WWW::Mechanize subclass
license: ~
-generated_by: ExtUtils::MakeMaker version 6.36
+author:
+ - Andy Lester <andy at petdance.com>
+generated_by: ExtUtils::MakeMaker version 6.44
distribution_type: module
requires:
Carp::Assert::More: 0
HTTP::Server::Simple: 0.07
+ HTTP::Server::Simple::CGI: 0
Test::Builder::Tester: 1.09
Test::LongString: 0.07
Test::More: 0
URI::file: 0
WWW::Mechanize: 1.24
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
-author:
- - Andy Lester <andy at petdance.com>
-resources:
- homepage: http://code.google.com/p/www-mechanize/
- bugtracker: http://code.google.com/p/www-mechanize/issues/list
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Modified: branches/upstream/libtest-www-mechanize-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/Makefile.PL?rev=27320&op=diff
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/Makefile.PL (original)
+++ branches/upstream/libtest-www-mechanize-perl/current/Makefile.PL Wed Nov 26 21:35:58 2008
@@ -9,13 +9,14 @@
ABSTRACT_FROM => 'Mechanize.pm',
PL_FILES => {},
PREREQ_PM => {
- 'Carp::Assert::More' => 0,
- 'HTTP::Server::Simple' => '0.07',
- 'Test::Builder::Tester' => '1.09',
- 'Test::LongString' => '0.07',
- 'Test::More' => 0,
- 'URI::file' => 0,
- 'WWW::Mechanize' => '1.24',
+ 'Carp::Assert::More' => 0,
+ 'HTTP::Server::Simple' => '0.07',
+ 'HTTP::Server::Simple::CGI' => 0,
+ 'Test::Builder::Tester' => '1.09',
+ 'Test::LongString' => '0.07',
+ 'Test::More' => 0,
+ 'URI::file' => 0,
+ 'WWW::Mechanize' => '1.24',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Test-WWW-Mechanize-*' },
Modified: branches/upstream/libtest-www-mechanize-perl/current/Mechanize.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/Mechanize.pm?rev=27320&op=diff
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/Mechanize.pm (original)
+++ branches/upstream/libtest-www-mechanize-perl/current/Mechanize.pm Wed Nov 26 21:35:58 2008
@@ -9,11 +9,11 @@
=head1 VERSION
-Version 1.18
-
-=cut
-
-our $VERSION = '1.20';
+Version 1.22
+
+=cut
+
+our $VERSION = '1.22';
=head1 SYNOPSIS
@@ -93,7 +93,7 @@
return $self;
}
-=head1 METHODS: GETTING & POSTING
+=head1 METHODS: HTTP VERBS
=head2 $mech->get_ok($url, [ \%LWP_options ,] $desc)
@@ -148,6 +148,59 @@
return $ok;
}
+=head2 $mech->head_ok($url, [ \%LWP_options ,] $desc)
+
+A wrapper around WWW::Mechanize's head(), with similar options, except
+the second argument needs to be a hash reference, not a hash. Like
+well-behaved C<*_ok()> functions, it returns true if the test passed,
+or false if not.
+
+A default description of "HEAD $url" is used if none if provided.
+
+=cut
+
+sub head_ok {
+ my $self = shift;
+ my $url = shift;
+
+ my $desc;
+ my %opts;
+
+ if ( @_ ) {
+ my $flex = shift; # The flexible argument
+
+ if ( !defined( $flex ) ) {
+ $desc = shift;
+ }
+ elsif ( ref $flex eq 'HASH' ) {
+ %opts = %{$flex};
+ $desc = shift;
+ }
+ elsif ( ref $flex eq 'ARRAY' ) {
+ %opts = @{$flex};
+ $desc = shift;
+ }
+ else {
+ $desc = $flex;
+ }
+ } # parms left
+
+ $self->head( $url, %opts );
+ my $ok = $self->success;
+
+ if ( not defined $desc ) {
+ $url = $url->url if ref($url) eq 'WWW::Mechanize::Link';
+ $desc = "HEAD $url";
+ }
+ $Test->ok( $ok, $desc );
+ if ( !$ok ) {
+ $Test->diag( $self->status );
+ $Test->diag( $self->response->message ) if $self->response;
+ }
+
+ return $ok;
+}
+
=head2 $mech->post_ok( $url, [ \%LWP_options ,] $desc )
A wrapper around WWW::Mechanize's post(), with similar options, except
@@ -200,6 +253,57 @@
return $ok;
}
+=head2 $mech->put_ok( $url, [ \%LWP_options ,] $desc )
+
+A wrapper around WWW::Mechanize's put(), with similar options, except
+the second argument needs to be a hash reference, not a hash. Like
+well-behaved C<*_ok()> functions, it returns true if the test passed,
+or false if not.
+
+A default description of "PUT to $url" is used if none if provided.
+
+=cut
+
+sub put_ok {
+ my $self = shift;
+ my $url = shift;
+
+ my $desc;
+ my %opts;
+
+ if ( @_ ) {
+ my $flex = shift; # The flexible argument
+
+ if ( !defined( $flex ) ) {
+ $desc = shift;
+ }
+ elsif ( ref $flex eq 'HASH' ) {
+ %opts = %{$flex};
+ $desc = shift;
+ }
+ elsif ( ref $flex eq 'ARRAY' ) {
+ %opts = @{$flex};
+ $desc = shift;
+ }
+ else {
+ $desc = $flex;
+ }
+ } # parms left
+
+ if ( not defined $desc ) {
+ $url = $url->url if ref($url) eq 'WWW::Mechanize::Link';
+ $desc = "PUT $url";
+ }
+ $self->put( $url, \%opts );
+ my $ok = $self->success;
+ $Test->ok( $ok, $desc );
+ if ( !$ok ) {
+ $Test->diag( $self->status );
+ $Test->diag( $self->response->message ) if $self->response;
+ }
+
+ return $ok;
+}
=head2 submit_form_ok( \%parms [, $desc] )
Added: branches/upstream/libtest-www-mechanize-perl/current/t/head_ok-parms.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/t/head_ok-parms.t?rev=27320&op=file
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/t/head_ok-parms.t (added)
+++ branches/upstream/libtest-www-mechanize-perl/current/t/head_ok-parms.t Wed Nov 26 21:35:58 2008
@@ -1,0 +1,49 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 16;
+use Test::Builder::Tester;
+
+BEGIN {
+ use_ok( 'Test::WWW::Mechanize' );
+}
+
+my $ua_args;
+
+sub Test::WWW::Mechanize::success { return 1; }
+sub Test::WWW::Mechanize::head {
+ my $self = shift;
+ my $url = shift;
+ use Data::Dumper;
+ $ua_args = {@_};
+ print Dumper( \@_ ) if @_ % 2;
+ return 1;
+}
+
+my $mech = Test::WWW::Mechanize->new();
+isa_ok( $mech, 'Test::WWW::Mechanize' );
+
+my $url = 'dummy://url';
+$mech->head_ok( $url );
+ok( eq_hash( {}, $ua_args ), 'passing URL only' );
+
+$mech->head_ok( $url, 'Description' );
+ok( eq_hash( {}, $ua_args ), 'Passing description' );
+
+$mech->head_ok( $url, undef, 'Description' );
+ok( eq_hash( {}, $ua_args ), 'Passing undef for hash' );
+
+my $wanted = { foo=>1, bar=>2, baz=>3 };
+
+$mech->head_ok( $url, [ %{$wanted} ] );
+ok( eq_hash( $wanted, $ua_args ), 'Passing anonymous list for hash' );
+
+$mech->head_ok( $url, [ %{$wanted} ], 'Description' );
+ok( eq_hash( $wanted, $ua_args ), 'Passing anonymous list for hash' );
+
+$mech->head_ok( $url, { %{$wanted} } );
+ok( eq_hash( $wanted, $ua_args ), 'Passing anonymous array for hash' );
+
+$mech->head_ok( $url, { %{$wanted} }, 'Description' );
+ok( eq_hash( $wanted, $ua_args ), 'Passing anonymous array for hash' );
Added: branches/upstream/libtest-www-mechanize-perl/current/t/head_ok.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/t/head_ok.t?rev=27320&op=file
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/t/head_ok.t (added)
+++ branches/upstream/libtest-www-mechanize-perl/current/t/head_ok.t Wed Nov 26 21:35:58 2008
@@ -1,0 +1,95 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use Test::Builder::Tester;
+use URI::file;
+
+use constant PORT => 13432;
+
+use constant NONEXISTENT => 'http://blahblablah.xx-nonexistent.';
+BEGIN {
+ if ( gethostbyname( NONEXISTENT ) ) {
+ plan skip_all => 'Found an A record for the non-existent domain';
+ }
+}
+
+BEGIN {
+ $ENV{http_proxy} = ''; # All our tests are running on localhost
+ plan tests => 12;
+ use_ok( 'Test::WWW::Mechanize' );
+}
+
+
+my $server=TWMServer->new(PORT);
+my $pid=$server->background;
+ok( $pid,'HTTP Server started' ) or die "Can't start the server";
+sleep 1; # $server->background() may come back prematurely, so give it a second to fire up
+
+sub cleanup { kill(9,$pid) if !$^S };
+$SIG{__DIE__}=\&cleanup;
+
+my $mech=Test::WWW::Mechanize->new( autocheck => 0 );
+isa_ok($mech,'Test::WWW::Mechanize');
+
+GOOD_HEAD: { # Stop giggling, you!
+ my $goodlinks='http://localhost:'.PORT.'/goodlinks.html';
+
+ $mech->head($goodlinks);
+ ok($mech->success, 'sanity check: we can load goodlinks.html');
+
+ test_out('ok 1 - Try to HEAD goodlinks.html');
+ my $ok = $mech->head_ok($goodlinks, 'Try to HEAD goodlinks.html');
+ test_test('HEAD existing URI and reports success');
+ is( ref($ok), '', "head_ok() should only return a scalar" );
+ ok( $ok, "And the result should be true" );
+
+ # default desc
+ test_out("ok 1 - HEAD $goodlinks");
+ $mech->head_ok($goodlinks);
+ test_test('HEAD existing URI and reports success - default desc');
+}
+
+BAD_HEAD: {
+ my $badurl = "http://wango.nonexistent.xx-only-testing/";
+ $mech->head($badurl);
+ ok(!$mech->success, "sanity check: we can't load NONEXISTENT.html");
+
+ test_out( 'not ok 1 - Try to HEAD bad URL' );
+ test_fail( +3 );
+ test_diag( "500" );
+ test_diag( "Can't connect to wango.nonexistent.xx-only-testing:80 (Bad hostname 'wango.nonexistent.xx-only-testing')" );
+ my $ok = $mech->head_ok( $badurl, 'Try to HEAD bad URL' );
+ test_test( 'Fails to HEAD nonexistent URI and reports failure' );
+
+ is( ref($ok), '', "head_ok() should only return a scalar" );
+ ok( !$ok, "And the result should be false" );
+}
+
+
+cleanup();
+
+{
+ package TWMServer;
+ use base 'HTTP::Server::Simple::CGI';
+
+ sub handle_request {
+ my $self=shift;
+ my $cgi=shift;
+
+ my $file=(split('/',$cgi->path_info))[-1]||'index.html';
+ $file=~s/\s+//g;
+
+ if(-r "t/html/$file") {
+ if(my $response=do { local (@ARGV, $/) = "t/html/$file"; <> }) {
+ print "HTTP/1.0 200 OK\r\n";
+ print "Content-Type: text/html\r\nContent-Length: ",
+ length($response), "\r\n\r\n", $response;
+ return;
+ }
+ }
+
+ print "HTTP/1.0 404 Not Found\r\n\r\n";
+ }
+}
Added: branches/upstream/libtest-www-mechanize-perl/current/t/put_ok.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-www-mechanize-perl/current/t/put_ok.t?rev=27320&op=file
==============================================================================
--- branches/upstream/libtest-www-mechanize-perl/current/t/put_ok.t (added)
+++ branches/upstream/libtest-www-mechanize-perl/current/t/put_ok.t Wed Nov 26 21:35:58 2008
@@ -1,0 +1,95 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use Test::Builder::Tester;
+use URI::file;
+
+use constant PORT => 13432;
+
+use constant NONEXISTENT => 'http://blahblablah.xx-nonexistent.';
+BEGIN {
+ if ( gethostbyname( 'blahblahblah.xx-nonexistent.' ) ) {
+ plan skip_all => 'Found an A record for the non-existent domain';
+ }
+}
+
+BEGIN {
+ $ENV{http_proxy} = ''; # All our tests are running on localhost
+ plan tests => 12;
+ use_ok( 'Test::WWW::Mechanize' );
+}
+
+
+my $server=TWMServer->new(PORT);
+my $pid=$server->background;
+ok( $pid,'HTTP Server started' ) or die "Can't start the server";
+sleep 1; # $server->background() may come back prematurely, so give it a second to fire up
+
+sub cleanup { kill(9,$pid) if !$^S };
+$SIG{__DIE__}=\&cleanup;
+
+my $mech=Test::WWW::Mechanize->new( autocheck => 0 );
+isa_ok($mech,'Test::WWW::Mechanize');
+
+GOOD_PUT: {
+ my $goodlinks='http://localhost:'.PORT.'/goodlinks.html';
+
+ $mech->put($goodlinks);
+ ok($mech->success, 'sanity check: we can load goodlinks.html');
+
+ test_out('ok 1 - Try to PUT goodlinks.html');
+ my $ok = $mech->put_ok($goodlinks, 'Try to PUT goodlinks.html');
+ test_test('PUTs existing URI and reports success');
+ is( ref($ok), '', "put_ok() should only return a scalar" );
+ ok( $ok, "And the result should be true" );
+
+ # default desc
+ test_out("ok 1 - PUT $goodlinks");
+ $mech->put_ok($goodlinks);
+ test_test('PUTs existing URI and reports success - default desc');
+}
+
+BAD_PUT: {
+ my $badurl = "http://wango.nonexistent.xx-only-testing/";
+ $mech->put($badurl);
+ ok(!$mech->success, "sanity check: we can't load NONEXISTENT.html");
+
+ test_out( 'not ok 1 - Try to PUT bad URL' );
+ test_fail( +3 );
+ test_diag( "500" );
+ test_diag( "Can't connect to wango.nonexistent.xx-only-testing:80 (Bad hostname 'wango.nonexistent.xx-only-testing')" );
+ my $ok = $mech->put_ok( $badurl, 'Try to PUT bad URL' );
+ test_test( 'Fails to PUT nonexistent URI and reports failure' );
+
+ is( ref($ok), '', "put_ok() should only return a scalar" );
+ ok( !$ok, "And the result should be false" );
+}
+
+
+cleanup();
+
+{
+ package TWMServer;
+ use base 'HTTP::Server::Simple::CGI';
+
+ sub handle_request {
+ my $self=shift;
+ my $cgi=shift;
+
+ my $file=(split('/',$cgi->path_info))[-1]||'index.html';
+ $file=~s/\s+//g;
+
+ if(-r "t/html/$file") {
+ if(my $response=do { local (@ARGV, $/) = "t/html/$file"; <> }) {
+ print "HTTP/1.0 200 OK\r\n";
+ print "Content-Type: text/html\r\nContent-Length: ",
+ length($response), "\r\n\r\n", $response;
+ return;
+ }
+ }
+
+ print "HTTP/1.0 404 Not Found\r\n\r\n";
+ }
+}
More information about the Pkg-perl-cvs-commits
mailing list