Debian Codegraph @

t/tesouro_direto.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 my @bounds = ("Tesouro Prefixado 2031", "Tesouro IPCA+ 2045", "Tesouro Renda+ Aposentadoria Extra 2065", "Tesouro Educa+ 2043");
11
12 plan tests => 1 + 8*(1+$#bounds) + 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("tesouro_direto", @bounds);
19 ok(%quotes);
20
21 foreach my $bound (@bounds) {
22 ok( $quotes{$bound, "success"}, "$bound success" );
23 is( $quotes{$bound, "exchange"}, "Tesouro Direto", "$bound exchange correct" );
24 is( $quotes{$bound, "name"}, $bound, "$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"}, "tesouro_direto", "$bound method correct" );
29 is( $quotes{$bound, "currency"}, "BRL", "$bound currency correct" );
30 }
31
32 %quotes = $q->fetch( "tesouro_direto", "BOGUS" );
33 ok( !$quotes{ "BOGUS", "success" }, "BOGUS failed" );