Skip Menu |

This queue is for tickets about the Flickr-API CPAN distribution.

Report information
The Basics
Id: 18240
Status: resolved
Priority: 0/
Queue: Flickr-API

People
Owner: Nobody in particular
Requestors: murray [...] minty.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.07
Fixed in: 0.08



Subject: two unit tests are failing
re: Flickr::API v 0.07, Perl 5.8, Kubuntu Linux (Breezy) Unit tests 2 and 5 appear to be broken atm. Below are patches that should address this. I've seperated the patches out inline to explain what is going on. The attached file applies all these patches in one go. First up, a patch that improves the unit tests. $ diff old_test.pl test.pl 1c1 < use Test; --- Show quoted text
> use Test::More;
24c24,25 < ok($rsp->{error_code} == 0); # this error code will change in future! --- Show quoted text
> # this error code will change in future! > is($rsp->{error_code},0, 'checking the error code for "method not
found"'); Second, this test still fails but now tells us it got 112 when it was expecting 0. I think this agrees with http://www.flickr.com/services/api/flickr.reflection.getMethods.html Thus, assuming you are willing to apply the above patch, then this second patch will fix the error code issue $ diff old_test.pl test.pl 25c25 < is($rsp->{error_code},0, 'checking the error code for "method not found"'); --- Show quoted text
> is($rsp->{error_code},112, 'checking the error code for "method not
found"'); Then there is test 5 which was failing. First I changed the ok() call to a Test::More::is() call $ diff old_test.pl test.pl 46c46 < ok($uri->query eq 'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key'); --- Show quoted text
> is($uri->query,
'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key', 'check the query matches what we expect'); Rerunning the test now returns: not ok 5 - check the query matches what we expect # Failed test (test.pl at line 46) # got: 'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&frob=my_frob&perms=r&api_key=made_up_key' # expected: 'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key' Which are identical except that the 'perms' and 'frob' parameters are in opposite positions. I'm not sure if this order is random, or just changed, but I'd propose the following patch to test.pl 2c2 < BEGIN { plan tests => 8 }; --- Show quoted text
> BEGIN { plan tests => 16 };
46c46,62 < is($uri->query, 'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key', 'check the query matches what we expect'); --- Show quoted text
> my %expect =
&parse_query('api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key'); Show quoted text
> my %got = &parse_query($uri->query); > sub parse_query { > my %hash; > foreach my $pair (split(/\&/, shift)) { > my ($name, $value) = split(/\=/, $pair); > $hash{$name} = $value; > } > return(%hash); > } > foreach my $item (keys %expect) { > is($expect{$item}, $got{$item}, "Checking that the $item item in
the query matches"); Show quoted text
> } > foreach my $item (keys %got) { > is($expect{$item}, $got{$item}, "Checking that the $item item in
the query matches in reverse"); Show quoted text
> } >
Subject: unit_test_0_07.patch
--- old_test.pl 2006-03-19 11:02:43.000000000 +0000 +++ test.pl 2006-03-19 11:19:32.000000000 +0000 @@ -1,5 +1,5 @@ -use Test; -BEGIN { plan tests => 8 }; +use Test::More; +BEGIN { plan tests => 16 }; use Flickr::API; ok(1); # @@ -21,7 +21,8 @@ # check we get the 'method not found' error # -ok($rsp->{error_code} == 0); # this error code will change in future! +# this error code will change in future! +is($rsp->{error_code},112, 'checking the error code for "method not found"'); #print "code was $rsp->{error_code}, msg was $rsp->{error_message}\n"; @@ -42,7 +43,23 @@ my $uri = $api->request_auth_url('r', 'my_frob'); -ok($uri->query eq 'api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key'); +my %expect = &parse_query('api_sig=d749e3a7bd27da9c8af62a15f4c7b48f&perms=r&frob=my_frob&api_key=made_up_key'); +my %got = &parse_query($uri->query); +sub parse_query { + my %hash; + foreach my $pair (split(/\&/, shift)) { + my ($name, $value) = split(/\=/, $pair); + $hash{$name} = $value; + } + return(%hash); +} +foreach my $item (keys %expect) { + is($expect{$item}, $got{$item}, "Checking that the $item item in the query matches"); +} +foreach my $item (keys %got) { + is($expect{$item}, $got{$item}, "Checking that the $item item in the query matches in reverse"); +} + ok($uri->path eq '/services/auth'); ok($uri->host eq 'flickr.com'); ok($uri->scheme eq 'http');