diff --git a/tests/testthat/test-get_resource.R b/tests/testthat/test-get_resource.R index e5917e1..f502f58 100644 --- a/tests/testthat/test-get_resource.R +++ b/tests/testthat/test-get_resource.R @@ -124,3 +124,22 @@ test_that("errors on invalid filters", { regexp = "col_select: invalid value" ) }) + +test_that("We can filter data with `Sex = 'All'`", { + pops <- get_resource( + res_id = "27a72cc8-d6d8-430c-8b4f-3109a9ceadb1", + row_filters = list("Sex" = "All"), + col_select = c("Year", "HB", "AllAges", "Sex") + ) + + expect_s3_class(pops, "tbl_df") + expect_equal(nrow(pops), 645) + expect_named(pops, c( + "Year", + "HB", + "AllAges", + "Sex" + )) + expect_length(unique(pops$HB), 15) + expect_setequal(pops$Sex, "All") +}) diff --git a/tests/testthat/test-parse_row_filters.R b/tests/testthat/test-parse_row_filters.R index 62f9b5e..040cdc6 100644 --- a/tests/testthat/test-parse_row_filters.R +++ b/tests/testthat/test-parse_row_filters.R @@ -29,6 +29,23 @@ test_that("returns FALSE for length > 1", { ) }) +test_that("returns FALSE if `Sex = 'All'` is given", { + expect_false( + parse_row_filters(list("Sex" = "All")) + ) + + expect_false( + parse_row_filters(list("Sex" = c("Male", "All"))) + ) + + expect_false( + parse_row_filters(list( + "Sex" = "All", + "HBT" = "S1234" + )) + ) +}) + test_that("throws error when un-named", { expect_error( parse_row_filters(list(1, 2)),