File: 012Keyword.t

package info (click to toggle)
libnet-amazon-perl 0.35-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 908 kB
  • ctags: 160
  • sloc: xml: 4,821; perl: 2,055; makefile: 46
file content (43 lines) | stat: -rwxr-xr-x 1,209 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

###########################################
# Keyword search tests
# Mike Schilli, 2004 (m@perlmeister.com)
###########################################
use warnings;
use strict;

use Net::Amazon;
use Net::Amazon::Property;
use Net::Amazon::Request::Keyword;
use Test::More tests => 8;

################################################################
# Setup
################################################################
  my($TESTDIR) = map { -d $_ ? $_ : () } qw(t ../t .);
  require "$TESTDIR/init.pl";
  my $CANNED = "$TESTDIR/canned";
################################################################
  canned($CANNED, "keyword.xml");
################################################################

my $ua = Net::Amazon->new(
    token         => 'YOUR_AMZN_TOKEN',
    max_pages     => 5,
    response_dump => 1,
);

my $req = Net::Amazon::Request::Keyword->new(
    keyword   => "perl power",
    mode      => "books",
);

 # Response: Net::Amazon::Keyword::Response
my $resp = $ua->request($req);

ok($resp->is_success(), "Successful fetch");
my @properties = $resp->properties();
is(scalar @properties, 6, "6 hits");
for ($resp->properties) {
   like $_->Asin(), qr/^\d+[\dX]$/, "Check Asin";
}