From 55ef519ea1682dd87171ca4e6edaae661a4f9afd Mon Sep 17 00:00:00 2001 From: Jackson Hoffart Date: Wed, 6 Mar 2024 16:32:22 +0100 Subject: [PATCH 1/2] in tests, use new NACE classification codes --- tests/testthat/test-match_name.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-match_name.R b/tests/testthat/test-match_name.R index 36594ed7..3c863c3f 100644 --- a/tests/testthat/test-match_name.R +++ b/tests/testthat/test-match_name.R @@ -35,7 +35,7 @@ test_that("w/ missing values at all levels outputs 0-row", { 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( @@ -54,7 +54,7 @@ test_that("w/ 1 lbk row matching 1 abcd company in 2 sectors outputs 2 rows", { 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_, @@ -86,7 +86,7 @@ test_that("`by_sector = TRUE` yields only matching sectors", { test_that("w/ mismatching sector_classification and `by_sector = TRUE` yields no match", { # 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( @@ -379,7 +379,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 @@ -495,7 +495,7 @@ 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 + code_for_sector_power <- "D35.1" sector_not_power <- "coal" out <- match_name( From 6247132d5536efe3335ba1fc0be0af610b5fe031 Mon Sep 17 00:00:00 2001 From: Jackson Hoffart Date: Wed, 6 Mar 2024 16:40:19 +0100 Subject: [PATCH 2/2] skip tests requiring new codes with old .data --- tests/testthat/test-match_name.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testthat/test-match_name.R b/tests/testthat/test-match_name.R index 3c863c3f..e5b28bb6 100644 --- a/tests/testthat/test-match_name.R +++ b/tests/testthat/test-match_name.R @@ -29,6 +29,7 @@ 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_, @@ -48,6 +49,7 @@ 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( @@ -85,6 +87,7 @@ 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 <- "D35.1" sector_not_power <- "coal" @@ -495,6 +498,7 @@ 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 + skip_if_r2dii_data_outdated() code_for_sector_power <- "D35.1" sector_not_power <- "coal"