Skip to content

Commit

Permalink
Removed xafty_list_table from parameter in build_xafty_list and made …
Browse files Browse the repository at this point in the history
…the table an internal data object
  • Loading branch information
The Rational Optimist committed Nov 25, 2023
1 parent fb860d6 commit 7efeac0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ as.POSIXct_xafty <- function(datetimes, tz = "") {
#' @param validity_table Data Frame. A validation table that stores the rules that the check table will be checked against.
#' @param meta_tests_name Character. Name of the list item that stores all meta_tests. The parameter is there to help avoid naming
#' conflicts with column names from the check table or validity table.
#' @param xafty_rules_table Data Frame. The table object with the same name, bundled in the xafty package.
#' @param check_names Boolean. Adds a meta test that checks whether all column names of the validity table are present in
#' the check table.
#' @param check_number Boolean. Adds a meta test that checks whether the number of columns in the check table are equal or
#' larger than the columns in the validity table.
#' @returns A list.
#' @export
build_xafty_list <- function(check_table, validity_table, xafty_rules_table,
build_xafty_list <- function(check_table, validity_table,
meta_tests_name = "meta_tests", check_names = TRUE, check_number = TRUE) {

validity_table <- add_regex_columns_to_validity(check_table = check_table, validity_table = validity_table,
Expand Down
3 changes: 0 additions & 3 deletions man/build_xafty_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/test-build_xafty_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test_that("Xafty List shows all rules as true if all rules are fullfilled", {

check_table <- align_column_types(check_table = check_table, validity_table = validity_table)

xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table, xafty_rules_table = xafty_rules_table,
xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table,
check_names = FALSE, check_number = FALSE)

summary_test_table <- build_xafty_test_table(xafty_list = xafty_list)
Expand Down Expand Up @@ -68,7 +68,7 @@ test_that("Regex columns is supported in xafty list function", {

check_table <- align_column_types(check_table = check_table, validity_table = validity_table)

xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table, xafty_rules_table = xafty_rules_table)
xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table)

summary_xafty_table <- build_xafty_test_table(xafty_list = xafty_list)$test_result

Expand Down Expand Up @@ -102,7 +102,7 @@ test_that("Xafty_list can filter bad dates in a data set", {
"Wagon_Design" = c("##!!number", "##!!regexcolumns", "^W[1-9]", "333", "##!!notempty")
)

xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table, xafty_rules_table = xafty_rules_table)
xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table)
expect_equal(check_table$Expiration_Date[xafty_list$Expiration_Date$date$filter_result], "2021.04-25")
})

Expand Down Expand Up @@ -131,7 +131,7 @@ test_that("Column missing in check_table works with build_xafty_list", {
"Wagon_Design" = c("##!!number", "##!!regexcolumns", "^W[1-9]", "333", "##!!notempty")
)

xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table, xafty_rules_table = xafty_rules_table)
xafty_list <- build_xafty_list(check_table = check_table, validity_table = validity_table)

expect_equal(colnames(validity_table)[xafty_list$meta_tests$xafty_column_names$filter_result$colnames_validity_table],
"Product_Name")
Expand Down

0 comments on commit 7efeac0

Please sign in to comment.