Show
Ignore:
Timestamp:
04/18/08 16:58:49 (8 months ago)
Author:
daisuke
Message:

lang/perl/WebService-Simple; make the test accept a flickr API, and actually parse the response

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WebService-Simple/branch/lwp-base/t/01_basic.t

    r9681 r9687  
    11use strict; 
    2 use Test::More (tests => 5); 
     2use Test::More; 
    33 
     4my ($flickr_api_key); 
    45BEGIN 
    56{ 
     7    $flickr_api_key = $ENV{FLICKR_API_KEY}; 
     8    if (! $flickr_api_key ) { 
     9        plan( skip_all => "Please set FLICKR_API_KEY to enable this test" ); 
     10    } else { 
     11        plan( tests => 10 ); 
     12    } 
     13 
    614    use_ok("WebService::Simple"); 
    715} 
     
    1018    my $simple = WebService::Simple->new( 
    1119        base_url => "http://api.flickr.com/services/rest/", 
     20        params   => { 
     21            api_key => $flickr_api_key 
     22        } 
    1223    ); 
    1324 
     
    1627    ok( $simple->response_parser, "parser ok" ); 
    1728    isa_ok( $simple->response_parser, "WebService::Simple::Parser::XML::Simple", "parser isa WebService::Simple::Parser::XML::Simple" ); 
     29 
     30    my $response = $simple->get( { method => "flickr.test.echo", name => "value" } ); 
     31 
     32    ok( $response ); 
     33    isa_ok( $response, "WebService::Simple::Response" ); 
     34 
     35    my $h = $response->parse_response; 
     36    ok($h); 
     37    isa_ok($h, 'HASH'); 
     38 
     39    is( $h->{name}, 'value' ); 
    1840}