Debian Codegraph @

t/deka.t

raw
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 plan tests => 13;
11
12 my $q = Finance::Quote->new("Deka");
13 $q->timeout(60);
14
15 my $year = (localtime())[5] + 1900;
16 my $lastyear = $year - 1;
17 my @stocks = ("DE0008474511","LU0051755006");
18 my %quotes = $q->deka(@stocks, "BOGUS");
19 ok(%quotes);
20
21 foreach my $stock (@stocks) {
22 ok($quotes{$stock,"success"});
23 ok($quotes{$stock,"last"} > 0);
24 ok(substr($quotes{$stock,"isodate"},0,4) == $year ||
25 substr($quotes{$stock,"isodate"},0,4) == $lastyear);
26 ok(substr($quotes{$stock,"date"},6,4) == $year ||
27 substr($quotes{$stock,"date"},6,4) == $lastyear);
28 }
29 ok($quotes{"DE0008474511","currency"} eq "EUR");
30 ok($quotes{"LU0051755006","currency"} eq "USD");
31
32
33 # Check that a bogus fund returns no-success.
34 ok($quotes{"BOGUS","success"} == 0);
35 ok($quotes{"BOGUS","errormsg"} eq "No data returned");