root/lang/perl/WebService-Simple/tags/release-0.05/t/02_parser_xml_simple.t @ 10306

Revision 10117, 0.9 kB (checked in by daisuke, 6 years ago)

more testing using flickr

Line 
1use strict;
2use Test::More ( tests => 4 );
3
4my $flickr_api_key = $ENV{FLICKR_API_KEY};
5BEGIN
6{
7    use_ok("WebService::Simple");
8}
9
10{
11    my $service = WebService::Simple->new(
12        base_url => "http://api.flickr.com/services/rest/",
13        params   => {
14            api_key => $flickr_api_key
15        }
16    );
17
18    isa_ok( $service->response_parser, "WebService::Simple::Parser::XML::Simple");
19
20    SKIP: {
21        if (! $flickr_api_key ) {
22            skip( "Please set FLICKR_API_KEY to enable this test", 2 );
23        }
24   
25        my $response = $service->get( { method => "flickr.test.echo", name => "value" } );
26        my $xml = $response->parse_response;
27   
28        isa_ok( $xml, 'HASH' );
29        is_deeply(
30            $xml,
31            {
32                'name' => 'value',
33                'method' => 'flickr.test.echo',
34                'api_key' => $flickr_api_key,
35                'stat' => 'ok'
36            }
37        );
38    }
39}
Note: See TracBrowser for help on using the browser.