-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04a6ea6
commit 016f649
Showing
8 changed files
with
258 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
test_that("it should fetch data from 12-months-infl market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IPCA" | ||
start_date <- "2018-06-22" | ||
end_date <- "2018-06-22" | ||
x <- get_twelve_months_inflation_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(NROW(x), 4) | ||
expect_equal(max(x$date), as.Date("2018-06-22")) | ||
}) | ||
|
||
test_that("it should fetch data from annual market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "Balança comercial" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_annual_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from monthly market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IPCA" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_monthly_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from monthly market expectations API without start_date", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IPCA" | ||
end_date <- "2018-01-31" | ||
x <- get_monthly_market_expectations(indic, end_date = end_date, `$top` = 10) | ||
expect_s3_class(x, "data.frame") | ||
}) | ||
|
||
test_that("it should fetch data from monthly market expectations API without end_date", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IPCA" | ||
start_date <- "2018-01-02" | ||
x <- get_monthly_market_expectations(indic, start_date = start_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(min(x$date), as.Date("2018-01-02")) | ||
}) | ||
|
||
test_that("it should fetch data from quarterly market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "PIB Total" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_quarterly_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 10) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from top 5s monthly market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IGP-M" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_top5s_monthly_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 9) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
|
||
# empty case | ||
indic <- "Selic" | ||
start_date <- "2022-01-01" | ||
end_date <- "2022-04-30" | ||
x <- get_top5s_monthly_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 0) | ||
}) | ||
|
||
test_that("it should fetch data from top 5s annual market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IGP-M" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_top5s_annual_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 9) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from institutions market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
indic <- "IGP-M" | ||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_institutions_market_expectations(indic, start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 7) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from selic market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_selic_market_expectations(start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 10) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) | ||
|
||
test_that("it should fetch data from top 5s selic market expectations API", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
start_date <- "2018-01-01" | ||
end_date <- "2018-01-31" | ||
x <- get_top5s_selic_market_expectations(start_date, end_date) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x)[2], 10) | ||
expect_equal(max(x$date), as.Date("2018-01-31")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
test_that("it should test odata currency", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
x <- olinda_get_currency("USD", "2017-03-01", "2017-03-02") | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(attr(x, "symbol"), "USD") | ||
|
||
bid <- Bid(x) | ||
ask <- Ask(x) | ||
expect_equal(names(bid), c("datetime", "USD")) | ||
expect_equal(names(ask), c("datetime", "USD")) | ||
|
||
x <- olinda_get_currency("USD", "2017-03-01", "2017-03-14", as = "xts") | ||
expect_s3_class(x, "xts") | ||
expect_equal(attr(x, "symbol"), "USD") | ||
|
||
x_ask <- Ask(x) | ||
x_bid <- Bid(x) | ||
expect_equal(colnames(x_ask), "USD") | ||
expect_equal(colnames(x_bid), "USD") | ||
}) | ||
|
||
test_that("it should test odata currency for single date", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
x <- olinda_get_currency("USD", "2017-03-01") | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(attr(x, "symbol"), "USD") | ||
expect_equal(as.Date(max(x$datetime)), as.Date("2017-03-01")) | ||
}) | ||
|
||
test_that("it should test odata currency with parity", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
x <- olinda_get_currency("USD", "2017-03-01", parity = TRUE) | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(attr(x, "symbol"), "USD") | ||
expect_equal(as.Date(max(x$datetime)), as.Date("2017-03-01")) | ||
expect_true(all(x$bid == 1)) | ||
expect_equal(x$bid, x$ask) | ||
}) | ||
|
||
test_that("it should test odata currency as text", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
x <- olinda_get_currency("USD", "2017-03-01", parity = TRUE, as = "text") | ||
expect_type(x, "character") | ||
}) | ||
|
||
test_that("it should test odata list currencis", { | ||
if (!covr::in_covr()) { | ||
skip_on_cran() | ||
skip_if_offline() | ||
} | ||
|
||
x <- olinda_list_currencies() | ||
expect_s3_class(x, "data.frame") | ||
expect_equal(dim(x), c(10, 3)) | ||
}) |