Changeset 10117

Show
Ignore:
Timestamp:
04/22/08 10:17:43 (6 months ago)
Author:
daisuke
Message:

more testing using flickr

Location:
lang/perl/WebService-Simple/trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WebService-Simple/trunk/Makefile.PL

    r10081 r10117  
    1515requires( 'XML::Simple' ); 
    1616 
     17recommends( 'XML::LibXML' ); 
     18 
    1719build_requires( 'Test::More' ); 
    1820build_requires( 'Test::Pod' ); 
  • lang/perl/WebService-Simple/trunk/t/02_parser_libxml.t

    r10077 r10117  
    22use Test::More; 
    33 
     4my $flickr_api_key = $ENV{FLICKR_API_KEY}; 
    45BEGIN 
    56{ 
     
    89        plan(skip_all => "XML::LibXML not installed"); 
    910    } else { 
    10         plan(tests => 2); 
     11        plan(tests => 7); 
    1112    } 
    1213    use_ok("WebService::Simple"); 
     
    1516{ 
    1617    my $service = WebService::Simple->new( 
    17         base_url => "http://example.com/hoge", 
    18         response_parser => "XML::LibXML" 
     18        base_url => "http://api.flickr.com/services/rest/", 
     19        response_parser => 'XML::LibXML', 
     20        params   => { 
     21            api_key => $flickr_api_key 
     22        } 
    1923    ); 
    2024    isa_ok( $service->response_parser, "WebService::Simple::Parser::XML::LibXML"); 
     25 
     26    SKIP: { 
     27        if (! $flickr_api_key ) { 
     28            skip( "Please set FLICKR_API_KEY to enable this test", 1 ); 
     29        } 
     30     
     31        my $response = $service->get( { method => "flickr.test.echo", name => "value" } ); 
     32        my $xml = $response->parse_response; 
     33     
     34        isa_ok( $xml, 'XML::LibXML::Document' ); 
     35        is( $xml->findvalue( '/rsp/@stat' ), 'ok', '/rsp/@stat' ); 
     36        is( $xml->findvalue( '/rsp/api_key' ), $flickr_api_key, '/rsp/api_key', ); 
     37        is( $xml->findvalue( '/rsp/name' ), "value", '/rsp/name' ); 
     38        is( $xml->findvalue( '/rsp/method' ), 'flickr.test.echo', '/rsp/method' ); 
     39    } 
    2140}