File: usfedbonds.t

package info (click to toggle)
libfinance-quote-perl 1.17-1%2Bdeb6u1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 896 kB
  • ctags: 359
  • sloc: perl: 7,272; makefile: 3
file content (63 lines) | stat: -rwxr-xr-x 2,052 bytes parent folder | download | duplicates (5)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w
use strict;
use Test::More;
use Finance::Quote;

if (not $ENV{ONLINE_TEST}) {
    plan skip_all => 'Set $ENV{ONLINE_TEST} to run this test';
}

plan tests => 19;

# Test usfedbonds functions.

my $year = (localtime())[5] + 1900;
my $lastyear = $year - 1;
my $q      = Finance::Quote->new("USFedBonds");

#my %quotes = $q->usfedbonds("E197001.200606");
my %quotes = $q->usfedbonds("E197001.200606","E194112.200610","E194101.200610","E194001.200610","BOGUS");
ok(%quotes);

TODO: {
  local $TODO="To be debugged";

  # Check that the last and date values are defined.
  ok($quotes{"E197001.200606","success"});
  ok($quotes{"E197001.200606","price"} > 0);
  ok(length($quotes{"E197001.200606","date"}) > 0);
  ok(substr($quotes{"E197001.200606","isodate"},0,4) eq $year ||
       substr($quotes{"E197001.200606","isodate"},0,4) eq $lastyear);
  ok(substr($quotes{"E197001.200606","date"},6,4) eq $year ||
       substr($quotes{"E197001.200606","date"},6,4) eq $lastyear);
  ok($quotes{"E197001.200606","currency"} eq "USD");

  ok($quotes{"E194112.200610","success"});
  ok($quotes{"E194112.200610","price"} > 0);
  ok(length($quotes{"E194112.200610","date"}) > 0);
  ok(substr($quotes{"E194112.200610","isodate"},0,4) eq $year ||
       substr($quotes{"E194112.200610","isodate"},0,4) eq $lastyear);
  ok(substr($quotes{"E194112.200610","date"},6,4) eq $year ||
       substr($quotes{"E194112.200610","date"},6,4) eq $lastyear);
  ok($quotes{"E194112.200610","currency"} eq "USD");
}

# Check that a non-existent price returns no-success.
ok($quotes{"E194101.200610","success"} == 0);

TODO: {
  local $TODO="To be debugged";
  ok($quotes{"E194101.200610","errormsg"} eq "No value found");
}

# Check that a non-existent price returns no-success.
ok($quotes{"E194001.200610","success"} == 0);

TODO: {
  local $TODO="To be debugged";
  ok($quotes{"E194001.200610","errormsg"} eq "Date not found");
}

# Check that a bogus fund returns no-success.
ok($quotes{"BOGUS","success"} == 0);
ok($quotes{"BOGUS","errormsg"} eq "Parse error");