diff --git a/R/mainTests.r b/R/mainTests.r index 89f0241a..e8636fe1 100644 --- a/R/mainTests.r +++ b/R/mainTests.r @@ -1520,9 +1520,10 @@ country_combinations <- function(data) { # check that there is a 1:1 relationship between geography codes and names lower_level_geog_names <- geography_matrix[9:12, 2:3] %>% as.character() # skipping school/prov as they have legit duplicates +lower_level_geog_levels <- geography_matrix[9:12, 1] %>% as.character() other_geography_duplicates <- function(data) { - if (!any(lower_level_geog_names %in% names(data))) { + if (!any(lower_level_geog_levels %in% unique(data$geographic_level))) { output <- list( "message" = "Lower-level geography data is not present in this data file.", "result" = "IGNORE" @@ -1593,9 +1594,10 @@ other_geography_duplicates <- function(data) { # check that there is a 1:1 relationship between geography names and codes lower_level_geog_names <- geography_matrix[9:12, 2:3] %>% as.character() # skipping school/prov as they have legit duplicates +lower_level_geog_levels <- geography_matrix[9:12, 1] %>% as.character() other_geography_code_duplicates <- function(data) { - if (!any(lower_level_geog_names %in% names(data))) { + if (!any(lower_level_geog_levels %in% unique(data$geographic_level))) { output <- list( "message" = "Lower-level geography data is not present in this data file.", "result" = "IGNORE" diff --git a/tests/testthat/sch_prov/school_with_trust.csv b/tests/testthat/sch_prov/school_with_trust.csv new file mode 100644 index 00000000..8f824053 --- /dev/null +++ b/tests/testthat/sch_prov/school_with_trust.csv @@ -0,0 +1,7 @@ +time_identifier,time_period,geographic_level,country_code,country_name,region_code,region_name,old_la_code,new_la_code,la_name,estab,school_laestab,school_urn,school_name,trust_name,academy_type,academy_open_date,school_type,headcount,perm_excl,perm_excl_rate,suspension,susp_rate,one_plus_susp,one_plus_susp_rate +Spring term,202122,School,E92000001,England,E13000001,Inner London,201,E09000001,City of London,3614,2013614,100000,The Aldgate School,z,z,z,State-funded primary,277,0,0,0,0,0,0 +Autumn term,202122,School,E92000001,England,E13000001,Inner London,201,E09000001,City of London,3614,2013614,100000,The Aldgate School,z,z,z,State-funded primary,269,0,0,0,0,0,0 +Autumn term,202122,School,E92000001,England,E13000001,Inner London,202,E09000007,Camden,2000,2022000,136807,St Luke's Church of England School,ST LUKE'S CHURCH OF ENGLAND SCHOOL,z,z,State-funded primary,101,0,0,0,0,0,0 +Spring term,202122,School,E92000001,England,E13000001,Inner London,202,E09000007,Camden,2000,2022000,136807,St Luke's Church of England School,ST LUKE'S CHURCH OF ENGLAND SCHOOL,z,z,State-funded primary,102,0,0,0,0,0,0 +Autumn term,202122,School,E92000001,England,E13000001,Inner London,202,E09000007,Camden,2001,2022001,139837,Abacus Belsize Primary School,ANTHEM SCHOOLS TRUST,z,z,State-funded secondary,156,0,0,0,0,0,0 +Spring term,202122,School,E92000001,England,E13000001,Inner London,202,E09000007,Camden,2001,2022001,139837,Abacus Belsize Primary School,ANTHEM SCHOOLS TRUST,z,z,State-funded secondary,163,0,0,0,0,0,0 diff --git a/tests/testthat/sch_prov/school_with_trust.meta.csv b/tests/testthat/sch_prov/school_with_trust.meta.csv new file mode 100644 index 00000000..34e7cb15 --- /dev/null +++ b/tests/testthat/sch_prov/school_with_trust.meta.csv @@ -0,0 +1,9 @@ +col_name,col_type,label,indicator_grouping,indicator_unit,indicator_dp,filter_hint,filter_grouping_column +school_type,Filter,School Type,,,,"State-funded primary, secondary and special", +headcount,Indicator,Headcount,,,0,, +perm_excl,Indicator,Permanent exclusions,,,0,, +perm_excl_rate,Indicator,Permanent exclusions (rate),,,2,, +suspension,Indicator,Suspensions,,,0,, +susp_rate,Indicator,Suspension (rate),,,2,, +one_plus_susp,Indicator,Pupil enrolments with one or more suspension,,,0,, +one_plus_susp_rate,Indicator,Pupil enrolments with one or moresuspension (rate),,,2,, diff --git a/tests/testthat/test-mainTests.R b/tests/testthat/test-mainTests.R index c32d04da..05fbda3d 100644 --- a/tests/testthat/test-mainTests.R +++ b/tests/testthat/test-mainTests.R @@ -202,7 +202,7 @@ test_that("other_geography_duplicates", { # other_geography_code_duplicates ------------------------------------------------------------------------------------------------------- -test_that("other_geography_duplicates", { +test_that("other_geography_code_duplicates", { expect_equal(testIndividualTest(pathStart, "other_geography_code_duplicates"), "FAIL") }) diff --git a/tests/testthat/test-screenFiles.R b/tests/testthat/test-screenFiles.R index 01c7dcf2..09a426f9 100644 --- a/tests/testthat/test-screenFiles.R +++ b/tests/testthat/test-screenFiles.R @@ -175,6 +175,13 @@ test_that("sch_filter_group", { expect_equal(screeningOutput$results %>% filter(result == "FAIL") %>% nrow(), 0) }) +test_that("sch_with_trust_cols", { + screeningOutput <- testOther("../../tests/testthat/sch_prov/school_with_trust.csv") + + expect_equal(screeningOutput$results %>% filter(test == "other_geography_duplicates") %>% pull(result) %>% unlist(use.names = FALSE), "IGNORE") + expect_equal(screeningOutput$results %>% filter(test == "other_geography_code_duplicates") %>% pull(result) %>% unlist(use.names = FALSE), "IGNORE") +}) + test_that("not_sch_but_one_filter", { screeningOutput <- testOther("../../tests/testthat/sch_prov/not_sch_but_one_filter.csv")