| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use Test::More; |
| 4 |
use Finance::Quote; |
| 5 |
|
| 6 |
use constant DEBUG => $ENV{DEBUG}; |
| 7 |
use if DEBUG, 'Smart::Comments'; |
| 8 |
|
| 9 |
if (not $ENV{ONLINE_TEST}) { |
| 10 |
plan skip_all => 'Set $ENV{ONLINE_TEST} to run this test'; |
| 11 |
} |
| 12 |
|
| 13 |
# Test IndiaMutual functions. |
| 14 |
|
| 15 |
my $q = Finance::Quote->new(); |
| 16 |
my @funds = ("102676", "103131", "INF194K01W88", "INF090I01FN7", |
| 17 |
"INF082J01127", "SIF-120", "INF754K30094"); |
| 18 |
my $year = (localtime())[5] + 1900; |
| 19 |
my $lastyear = $year - 1; |
| 20 |
|
| 21 |
plan tests => 6*@funds + 2; |
| 22 |
|
| 23 |
my %quotes = $q->fetch("indiamutual", @funds); |
| 24 |
ok(%quotes); |
| 25 |
|
| 26 |
### Quotes Hash: %quotes |
| 27 |
|
| 28 |
# Check that the name and nav are defined for all of the funds. |
| 29 |
foreach my $fund (@funds) { |
| 30 |
ok($quotes{$fund,"nav"} > 0); |
| 31 |
ok(length($quotes{$fund,"name"})); |
| 32 |
ok($quotes{$fund,"success"}); |
| 33 |
ok($quotes{$fund, "currency"} eq "INR"); |
| 34 |
ok(substr($quotes{$fund,"isodate"},0,4) == $year || |
| 35 |
substr($quotes{$fund,"isodate"},0,4) == $lastyear); |
| 36 |
ok(substr($quotes{$fund,"date"},6,4) == $year || |
| 37 |
substr($quotes{$fund,"date"},6,4) == $lastyear); |
| 38 |
} |
| 39 |
|
| 40 |
# Check that a bogus fund returns no-success. |
| 41 |
%quotes = $q->fetch("indiamutual", "BOGUS"); |
| 42 |
ok(! $quotes{"BOGUS","success"}); |