From 77cef40cea286c66a1c3ac9f168b0f88d5ab07c9 Mon Sep 17 00:00:00 2001 From: Elizabeth Wenk Date: Fri, 9 Feb 2024 09:55:56 +1100 Subject: [PATCH 1/3] Update testdata.R solves issue #150 --- R/testdata.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/R/testdata.R b/R/testdata.R index fcd90058..4b64e528 100644 --- a/R/testdata.R +++ b/R/testdata.R @@ -591,8 +591,14 @@ dataset_test_worker <- ) # Check that there are no duplicate `var_in` or `context_property` fields - context_properties <- sapply(metadata[["contexts"]], "[[", "context_property") - context_vars_in <- sapply(metadata[["contexts"]], "[[", "var_in") + + if(is.na(metadata[["contexts"]])) { + context_properties <- metadata[["contexts"]] + context_vars_in <- metadata[["contexts"]] + } else { + context_properties <- sapply(metadata[["contexts"]], "[[", "context_property") + context_vars_in <- sapply(metadata[["contexts"]], "[[", "var_in") + } expect_equal( context_properties |> duplicated() |> sum(), From 9429f3631b076e8d91360540e1ed0a9d69a0b74d Mon Sep 17 00:00:00 2001 From: ehwenk Date: Wed, 13 Mar 2024 15:08:58 +1100 Subject: [PATCH 2/3] Update testdata.R Remove check for units in unit_conversions - this isn't expected. The `unit_in` field can also be a data.csv column. Or there can be units that are used, but happen to not be in the unit_conversions because there aren't any instances where they require converting. Noted in issue #146 as well. --- R/testdata.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/testdata.R b/R/testdata.R index 4b64e528..64697db6 100644 --- a/R/testdata.R +++ b/R/testdata.R @@ -737,12 +737,15 @@ dataset_test_worker <- ) # Check units are found in `unit_conversions.csv` - units <- read_csv("config/unit_conversions.csv") - expect_is_in( - traits$unit_in, units$unit_from, - info = paste0(red(f), "\ttraits"), - label = "`unit_in`'s" - ) + # This test is being commented out, because fails anytime columns are read in + # or anytime there are units not in unit_conversions because they are never converted. + + #units <- read_csv("config/unit_conversions.csv") + #expect_is_in( + # traits$unit_in, units$unit_from, + # info = paste0(red(f), "\ttraits"), + # label = "`unit_in`'s" + #) # Check no duplicate `var_in`'s From 0a7b90bbff159c564856607d104d5a563ac8ff62 Mon Sep 17 00:00:00 2001 From: ehwenk Date: Fri, 15 Mar 2024 10:55:44 +1100 Subject: [PATCH 3/3] Update testdata.R fix --- R/testdata.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/testdata.R b/R/testdata.R index 64697db6..d2549253 100644 --- a/R/testdata.R +++ b/R/testdata.R @@ -592,7 +592,7 @@ dataset_test_worker <- # Check that there are no duplicate `var_in` or `context_property` fields - if(is.na(metadata[["contexts"]])) { + if(is.na(metadata[["contexts"]][1])) { context_properties <- metadata[["contexts"]] context_vars_in <- metadata[["contexts"]] } else {