-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
223 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
test_that("returns appropriate length integer vector", { | ||
market_share_target_reference_year <- 2023 | ||
time_horizon <- 5 | ||
output <- determine_relevant_years(market_share_target_reference_year, time_horizon) | ||
expect_vector(output, ptype = integer()) | ||
expect_length(output, time_horizon + 1) | ||
expect_contains(output, market_share_target_reference_year) | ||
expect_length(output, length(unique(output))) | ||
}) |
28 changes: 28 additions & 0 deletions
28
tests/testthat/test-prepare_ar_company_id__country_of_domicile.R
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,28 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
ar_company_id = c("123-AB", "456-CD"), | ||
country_of_domicile = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_ar_company_id__country_of_domicile(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("ar_company_id", "country_of_domicile")) | ||
expect_true(all(!is.na(output$ar_company_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_ar_company_id__country_of_domicile("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_ar_company_id__country_of_domicile(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `ar_company_id`s", { | ||
input <- data.frame( | ||
ar_company_id = c("123-AB", "123-AB"), | ||
country_of_domicile = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_ar_company_id__country_of_domicile(input)) | ||
}) |
28 changes: 28 additions & 0 deletions
28
tests/testthat/test-prepare_ar_company_id__credit_parent_ar_company_id.R
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,28 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
ar_company_id = c("123-AB", "456-CD"), | ||
credit_parent_ar_company_id = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_ar_company_id__credit_parent_ar_company_id(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("ar_company_id", "credit_parent_ar_company_id")) | ||
expect_true(all(!is.na(output$ar_company_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_ar_company_id__credit_parent_ar_company_id("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_ar_company_id__credit_parent_ar_company_id(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `ar_company_id`s", { | ||
input <- data.frame( | ||
ar_company_id = c("123-AB", "123-AB"), | ||
credit_parent_ar_company_id = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_ar_company_id__credit_parent_ar_company_id(input)) | ||
}) |
29 changes: 29 additions & 0 deletions
29
tests/testthat/test-prepare_company_id__creditor_company_id.R
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,29 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
company_id = c("123-AB", "456-CD"), | ||
creditor_company_id = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_company_id__creditor_company_id(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("company_id", "creditor_company_id")) | ||
expect_true(all(!is.na(output$company_id))) | ||
expect_true(all(!is.na(output$creditor_company_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_company_id__creditor_company_id("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_company_id__creditor_company_id(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `company_id`s", { | ||
input <- data.frame( | ||
company_id = c("123-AB", "123-AB"), | ||
creditor_company_id = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_company_id__creditor_company_id(input)) | ||
}) |
29 changes: 29 additions & 0 deletions
29
tests/testthat/test-prepare_factset_entity_id__ar_company_id.R
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,29 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
factset_id = c("123-AB", "456-CD"), | ||
company_id = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_factset_entity_id__ar_company_id(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("factset_entity_id", "ar_company_id")) | ||
expect_true(all(!is.na(output$factset_id))) | ||
expect_true(all(!is.na(output$company_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_factset_entity_id__ar_company_id("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_factset_entity_id__ar_company_id(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `factset_id`s", { | ||
input <- data.frame( | ||
factset_id = c("123-AB", "123-AB"), | ||
company_id = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_factset_entity_id__ar_company_id(input)) | ||
}) |
29 changes: 29 additions & 0 deletions
29
tests/testthat/test-prepare_factset_entity_id__credit_parent_id.R
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,29 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
factset_entity_id = c("123-AB", "456-CD"), | ||
credit_parent_id = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_factset_entity_id__credit_parent_id(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("factset_entity_id", "credit_parent_id")) | ||
expect_true(all(!is.na(output$factset_entity_id))) | ||
expect_true(all(!is.na(output$credit_parent_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_factset_entity_id__credit_parent_id("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_factset_entity_id__credit_parent_id(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `factset_entity_id`s", { | ||
input <- data.frame( | ||
factset_entity_id = c("123-AB", "123-AB"), | ||
credit_parent_id = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_factset_entity_id__credit_parent_id(input)) | ||
}) |
29 changes: 29 additions & 0 deletions
29
tests/testthat/test-prepare_factset_entity_id__security_mapped_sector.R
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,29 @@ | ||
test_that("returns a data frame with expected columns and no `NA`s", { | ||
input <- data.frame( | ||
factset_entity_id = c("123-AB", "456-CD"), | ||
security_mapped_sector = c("Power", "Oil&Gas") | ||
) | ||
|
||
output <- prepare_factset_entity_id__security_mapped_sector(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_identical(names(output), c("factset_entity_id", "security_mapped_sector")) | ||
expect_true(all(!is.na(output$factset_entity_id))) | ||
expect_true(all(!is.na(output$security_mapped_sector))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_factset_entity_id__security_mapped_sector("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have the necessary columns", { | ||
expect_error(prepare_factset_entity_id__security_mapped_sector(data.frame(x = 1L))) | ||
}) | ||
|
||
test_that("returns error if output has duplicated `factset_entity_id`s", { | ||
input <- data.frame( | ||
factset_entity_id = c("123-AB", "123-AB"), | ||
security_mapped_sector = c("Power", "Oil&Gas") | ||
) | ||
expect_error(prepare_factset_entity_id__security_mapped_sector(input)) | ||
}) |
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,18 @@ | ||
test_that("returns a data frame with the proper column and no `NA`s", { | ||
input <- data.frame( | ||
factset_fund_id = c("XXX", NA, "ZZZ") | ||
) | ||
|
||
output <- prepare_total_fund_list(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_true(all(!is.na(output$factset_fund_id))) | ||
}) | ||
|
||
test_that("returns error if input is not a data frame", { | ||
expect_error(prepare_total_fund_list("xxx")) | ||
}) | ||
|
||
test_that("returns error if input does not have `factset_fund_id` column", { | ||
expect_error(prepare_total_fund_list(data.frame(x = 1L))) | ||
}) |
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,24 @@ | ||
test_that("returns a data frame with proper asset type names", { | ||
input <- data.frame( | ||
issue_type_code = "XXX", | ||
asset_type = c( | ||
"Listed Equity", | ||
"Corporate Bond", | ||
"Fund", | ||
"Other", | ||
"XXX" | ||
) | ||
) | ||
|
||
proper_asset_type_names <- c( | ||
"Equity", | ||
"Bonds", | ||
"Funds", | ||
"Others" | ||
) | ||
|
||
output <- standardize_asset_type_names(input) | ||
|
||
expect_s3_class(output, class = "data.frame") | ||
expect_in(output$asset_type, proper_asset_type_names) | ||
}) |