Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

Commit

Permalink
Merge 9114312 into 840a1b3
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolepore committed Jan 13, 2020
2 parents 840a1b3 + 9114312 commit 790fd57
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/testthat/test-match_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,32 @@ expected_names_of_match_name_with_loanbook_demo <- c(
"source"
)

test_that("match_name with missmatching sector_classification yields no match", {
# loanbook's sector_classification_direct_loantaker and ald sector should
# match (lookup code to sectors via sector_clasiffication_df()$code).

# Here they match and we expect some match
lbk_mini1 <- tibble::tibble(
id_ultimate_parent = "UP15",
name_ultimate_parent = "Alpine Knits India Pvt. Limited",
id_direct_loantaker = "C294",
name_direct_loantaker = "Yuamen Xinneng Thermal Power Co Ltd",
sector_classification_system = "NACE",
sector_classification_direct_loantaker = 27 # * code = 27 is sector power *
) # |
ald_mini <- tibble::tibble( # |
sector = "power", # * code = 27 is sector power *
name_company = "alpine knits india pvt. limited",
alias_ald = "alpineknitsindiapvt ltd"
)
expect_equal(nrow(match_name(lbk_mini1, ald_mini)), 1L)

# Here they do NOT match and we expect no match
ald_mini$sector <- "coal"
out <- expect_warning(match_name(lbk_mini1, ald_mini), "no match")
expect_equal(nrow(out), 0L)
})

test_that("match_name w/ row 1 of loanbook and crucial cols yields expected", {
# loanbook_demo %>% mini_lbk(1) %>% dput()
lbk_mini1 <- tibble::tibble(
Expand Down Expand Up @@ -69,6 +95,11 @@ test_that("match_name w/ row 1 of loanbook and crucial cols yields expected", {
sector_classification_direct_loantaker = 3511,
id = "UP1",
level = "ultimate_parent",
# ASK @jdhoffa: It seems strange that
# `sector_classification_direct_loantaker` refers to the level
# direct_loantaker but the match is at the level of ultimate_parent. Is this
# expected? (I guess so because loanbook_demo has no such column as
# sector_classification_ultimate_parent, but I'd like to understand why.)
sector = "power",
sector_ald = "power",
name = "Alpine Knits India Pvt. Limited",
Expand Down Expand Up @@ -324,3 +355,4 @@ test_that("match_name handles any number if intermediate_parent columns (#84)",
has_intermediate_parent <- any(grepl("intermediate_parent_1", output_levels))
expect_true(has_intermediate_parent)
})

0 comments on commit 790fd57

Please sign in to comment.