Skip to content

Commit

Permalink
Merge pull request #111 from dfe-analytical-services/meta-label-missi…
Browse files Browse the repository at this point in the history
…ng-bug

Meta label missing bug
  • Loading branch information
cjrace authored May 7, 2024
2 parents 087df78 + f0dc65e commit 64fcbfe
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/mainTests.r
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,7 @@ col_name_spaces <- function(meta) {
label <- function(meta) {
completed_labels <- meta %>%
filter(!is.na(label)) %>%
filter(label != "") %>%
nrow()

blank_labels <- nrow(meta) - completed_labels
Expand Down
15 changes: 14 additions & 1 deletion R/manual_scripts/debugging.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
# Debugging script
# Use this script to manually read in and screen files for those occasions when the app breaks without a useful error
# Helpful for running code in console
# Uncomment when you need to use this, and always make sure to comment it again before committing

# # Dependencies ==============================================================
# source("global.R")
# source("R/readFile.R")
# source("R/screenFiles.R")
# source("R/knownVariables.R")
# source("R/fileValidation.R")
# source("R/preCheck1.R")
# source("R/preCheck2.R")
# source("R/mainTests.R")
#
#
# debugReadFile <- function(file) {
# output <- readFile(file)
# output$filename <- basename(file)
# return(output)
# }
#
# # Put the file paths of the files in here
# # Choose files ==============================================================
# datafile <- debugReadFile(file.choose())
# metafile <- debugReadFile(file.choose())
#
# # Screen files ==============================================================
# results <- screenFiles(datafile$filename, metafile$filename, datafile$fileSeparator, metafile$fileSeparator, datafile$fileCharacter, metafile$fileCharacter, datafile$mainFile, metafile$mainFile)
#
# data.table(results$results) %>% View()
#
# # Extra helpers =============================================================
# data <- datafile$mainFile
# meta <- metafile$mainFile
#
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-UI-03_additional_qa.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,7 @@ test_that("Additional QA tabs", {
app$set_inputs(geog_indicator_parameter = "num_schools")
app$set_inputs(submit_geographies = "click")

app$wait_for_idle(5) # this test seems weirdly flaky for unknown reasons

app$expect_values(output = "geog_agg2")
})
7 changes: 7 additions & 0 deletions tests/testthat/test-data/label_blank_notNA.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
time_period,time_identifier,geographic_level,country_code,country_name,staff_count_type,some_number
202122,Academic year,National,E92000001,England,Admin,6
202122,Academic year,National,E92000001,England,Support,4
202122,Academic year,National,E92000001,England,Teacher,2
202122,Academic year,National,E92000001,England,Manager,6
202122,Academic year,National,E92000001,England,Leader,8
202122,Academic year,National,E92000001,England,Total,89098
3 changes: 3 additions & 0 deletions tests/testthat/test-data/label_blank_notNA.meta.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
col_name,col_type,label,indicator_grouping,indicator_unit,indicator_dp,filter_hint,filter_grouping_column
"staff_count_type","Filter","","","","","",""
"some_number","Indicator","Test indicator","","","0","",""
6 changes: 6 additions & 0 deletions tests/testthat/test-function-edge_cases.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@ test_that("prov_level_diff_names", {

expect_equal(screeningOutput$results %>% filter(result == "FAIL") %>% nrow(), 0)
})

test_that("blank_meta_label_notNA_still_fails", {
screeningOutput <- testOther("../../tests/testthat/test-data/label_blank_notNA.csv")

expect_equal(screeningOutput$results %>% filter(test == "label") %>% pull(result) %>% unlist(use.names = FALSE), "FAIL")
})

0 comments on commit 64fcbfe

Please sign in to comment.