Skip to content

Commit

Permalink
New tests generated for the filter_standard_cev funcion (desaparicion)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamadoa committed Feb 7, 2024
1 parent 13aeaab commit c28f822
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion tests/testthat/test-filter_standard_cev.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,60 @@ testthat::test_that("The function filter correct the age in reclutamiento", {

})

# Test desaparicion

desaparicion_data <- data.frame(
replica = c("R1", "R1", "R2", "R2"),
match_group_id = c("82294f9f7658711a56000977c65b8584ce91d7eb",
"74b133b3bac281bdcc8f4d8bbba7577a6261cc15",
"8d9421b878d7ca90766c3ba428acde0323aa05d8",
"95fbb67c05da4b928b9a40c75d9126b16aea1219"),
in_1 = c(0, 1, 0, 0),
in_6 = c(0, 1, 0, 0),
dept_code_hecho = c("50", "81", "11", "11"),
edad_categoria = c("10-14", "20-24", "15-19", "25-29"),
edad_categoria_imputed = c(FALSE, FALSE, FALSE, FALSE),
edad_jep = c("INFANCIA", "ADULTEZ", "ADULTEZ", "ADULTEZ"),
edad_jep_imputed = c(FALSE, FALSE, FALSE, FALSE),
etnia = c("INDIGENA", "MESTIZO", "NARP", "ROM"),
etnia_imputed = c(TRUE, FALSE, TRUE, TRUE),
is_conflict = c(TRUE, TRUE, TRUE, TRUE),
is_conflict_imputed = c(FALSE, FALSE, TRUE, FALSE),
is_forced_dis = c(TRUE, TRUE, FALSE, TRUE),
is_forced_dis_imputed = c(FALSE, FALSE, FALSE, FALSE),
muni_code_hecho = c("50001", "81794", "11001", "11001"),
muni_code_hecho_imputed = c(FALSE, FALSE, FALSE, FALSE),
p_str = c("EST", "GUE-ELN", "GUE-FARC", "GUE-OTRO"),
p_str_imputed = c(TRUE, FALSE, TRUE, TRUE),
sexo = c("HOMBRE", "MUJER"),
sexo_imputed = c(FALSE, FALSE, FALSE, FALSE),
yy_hecho = c("2010", "2002", "2013", "2011"),
yymm_hecho = c("201007", "200201", "201305", "201107")
)

testthat::test_that("The variables is_forced_dis and is_conflict are type
integer after applying the function", {

data_dis <- filter_standard_cev(desaparicion_data,
"desaparicion",
perp_change = TRUE)

testthat::expect_is(data_dis$is_forced_dis, "integer")
testthat::expect_is(data_dis$is_conflict, "integer")

})

testthat::test_that("The function generated correctly the variables
related to desaparicion", {

data_dis <- filter_standard_cev(desaparicion_data,
"desaparicion",
perp_change = TRUE)

testthat::expect_true("is_conflict_dis" %in% names(data_dis))
testthat::expect_true("is_conflict_dis_imputed" %in% names(data_dis))
testthat::expect_true("is_conflict_dis_rep" %in% names(data_dis))

})

# --- Done
# Done...

0 comments on commit c28f822

Please sign in to comment.