| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use Test::More; |
| 4 |
use Finance::Quote; |
| 5 |
|
| 6 |
if ( not $ENV{"ONLINE_TEST"} ) { |
| 7 |
plan skip_all => 'Set $ENV{ONLINE_TEST} to run this test'; |
| 8 |
} |
| 9 |
|
| 10 |
my @bonds = ("IT0000966017", "IT0001086567", "IT0005534984"); |
| 11 |
|
| 12 |
plan tests => 1 + 8*(1+$#bonds) + 1; |
| 13 |
|
| 14 |
my $q = Finance::Quote->new(); |
| 15 |
my $year = ( localtime() )[5] + 1900; |
| 16 |
my $lastyear = $year - 1; |
| 17 |
|
| 18 |
my %quotes = $q->fetch("borsa_italiana", @bonds); |
| 19 |
ok(%quotes); |
| 20 |
|
| 21 |
foreach my $bound (@bonds) { |
| 22 |
ok( $quotes{$bound, "success"}, "$bound success" ); |
| 23 |
is( $quotes{$bound, "exchange"}, "Borsa Italiana", "$bound exchange correct" ); |
| 24 |
ok( $quotes{$bound, "name"}, "$bound name correct" ); |
| 25 |
is( $quotes{$bound, "symbol"}, $bound, "$bound symbol correct" ); |
| 26 |
ok( $quotes{$bound, "price"} > 0, "$bound price positive" ); |
| 27 |
ok( $quotes{$bound, "last"} > 0, "$bound last positive" ); |
| 28 |
is( $quotes{$bound, "method"}, "borsa_italiana", "$bound method correct" ); |
| 29 |
is( $quotes{$bound, "currency"}, "EUR", "$bound currency correct" ); |
| 30 |
} |
| 31 |
|
| 32 |
%quotes = $q->fetch( "borsa_italiana", "BOGUS" ); |
| 33 |
ok( !$quotes{ "BOGUS", "success" }, "BOGUS failed" ); |