Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upkeep: update test values to align with new NACE code expectation #458

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tests/testthat/test-match_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ test_that("w/ non-NA only at intermediate level yields matches at intermediate
})

test_that("w/ missing values at all levels outputs 0-row", {
skip_if_r2dii_data_outdated()
lbk <- tibble(
id_direct_loantaker = NA_character_,
name_direct_loantaker = NA_character_,
id_ultimate_parent = NA_character_,
name_ultimate_parent = NA_character_,
sector_classification_system = "NACE",
sector_classification_direct_loantaker = 291,
sector_classification_direct_loantaker = "C29.10",
)

abcd <- tibble(
Expand All @@ -48,13 +49,14 @@ test_that("w/ missing values at all levels outputs 0-row", {
})

test_that("w/ 1 lbk row matching 1 abcd company in 2 sectors outputs 2 rows", {
skip_if_r2dii_data_outdated()
sector_abcd <- c("automotive", "shipping")

lbk <- tibble(
id_direct_loantaker = "C196",
name_direct_loantaker = "Suzuki Motor Corp",
sector_classification_system = "NACE",
sector_classification_direct_loantaker = 291,
sector_classification_direct_loantaker = "C29.10",

id_ultimate_parent = NA_character_,
name_ultimate_parent = NA_character_,
Expand Down Expand Up @@ -85,8 +87,9 @@ test_that("`by_sector = TRUE` yields only matching sectors", {

test_that("w/ mismatching sector_classification and `by_sector = TRUE` yields
no match", {
skip_if_r2dii_data_outdated()
# Lookup code to sectors via r2dii.data::sector_classifications$code
code_for_sector_power <- 27
code_for_sector_power <- "D35.1"
sector_not_power <- "coal"

expect_warning(
Expand Down Expand Up @@ -379,7 +382,7 @@ test_that("warns/errors if some/all system classification is unknown", {
)

bad <- -999
some_bad_code <- fake_lbk(sector_classification_direct_loantaker = c(35, bad))
some_bad_code <- fake_lbk(sector_classification_direct_loantaker = c("D35.1", bad))

suppressWarnings(
# In this expectation, we only care about this specific warning
Expand Down Expand Up @@ -495,7 +498,8 @@ test_that("with loanbook_demo and abcd_demo outputs expected value", {
test_that("w/ mismatching sector_classification and `by_sector = FALSE` yields
a match", {
# Lookup code to sectors via r2dii.data::sector_classifications$code
code_for_sector_power <- 27
skip_if_r2dii_data_outdated()
code_for_sector_power <- "D35.1"
sector_not_power <- "coal"

out <- match_name(
Expand Down
Loading