Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

471 remove CodeClass from FilteredData #964

Merged
merged 22 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
amend unit tests
Aleksander Chlebowski committed Nov 22, 2023
commit db058c95010fd3ea71a356b5249e65b61df3d4e2
39 changes: 11 additions & 28 deletions tests/testthat/test-module_nested_tabs.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
filtered_data <- teal.slice::init_filtered_data(
list(iris = list(dataset = head(iris)))
)
teal_data <- teal.data::teal_data() |> within(iris <- head(iris))
datanames(teal_data) <- "iris"
filtered_data <- teal_data_to_filtered_data(teal_data)

test_module1 <- module(
label = "test1",
@@ -36,22 +36,12 @@ test_module_wdata <- function(datanames) {
}

get_example_filtered_data <- function() {
d1 <- data.frame(id = 1:5, pk = c(2, 3, 2, 1, 4), val = 1:5)
d2 <- data.frame(id = 1:5, value = 1:5)

cc <- teal.data:::CodeClass$new()
cc$set_code("d1 <- data.frame(id = 1:5, pk = c(2,3,2,1,4), val = 1:5)", "d1")
cc$set_code("d2 <- data.frame(id = 1:5, value = 1:5)", "d2")

teal.slice::init_filtered_data(
x = list(
d1 = list(dataset = d1, metadata = list("A" = 1)),
d2 = list(dataset = d2)
),
join_keys = teal.data::join_keys(teal.data::join_key("d1", "d2", c("pk" = "id"))),
code = cc,
check = TRUE
)
td <- teal.data::teal_data()
td <- within(td, d1 <- data.frame(id = 1:5, pk = c(2, 3, 2, 1, 4), val = 1:5))
td <- within(td, d2 <- data.frame(id = 1:5, value = 1:5))
datanames(td) <- c("d1", "d2")
teal.data::join_keys(td) <- teal.data::join_keys(teal.data::join_key("d1", "d2", c("pk" = "id")))
teal_data_to_filtered_data(td)
}


@@ -461,22 +451,15 @@ testthat::test_that(".datasets_to_data returns tdata object", {
c(
get_rcode_str_install(),
get_rcode_libraries(),
"d1 <- data.frame(id = 1:5, pk = c(2, 3, 2, 1, 4), val = 1:5)\nd2 <- data.frame(id = 1:5, value = 1:5)\n\n",
"d1 <- data.frame(id = 1:5, pk = c(2, 3, 2, 1, 4), val = 1:5)\n\n",
"d2 <- data.frame(id = 1:5, value = 1:5)\n\n",
paste0(
"stopifnot(rlang::hash(d1) == \"f6f90d2c133ca4abdeb2f7a7d85b731e\")\n",
"stopifnot(rlang::hash(d2) == \"6e30be195b7d914a1311672c3ebf4e4f\") \n\n"
),
""
)
)

# metadata
testthat::expect_equal(
get_metadata(data, "d1"),
list(A = 1)
)

testthat::expect_null(get_metadata(data, "d2"))
})

testthat::test_that("calculate_hashes takes a FilteredData and vector of datanames as input", {
9 changes: 3 additions & 6 deletions tests/testthat/test-module_tabs_with_filters.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
filtered_data <- teal.slice::init_filtered_data(
list(
iris = list(dataset = head(iris)),
mtcars = list(dataset = head(mtcars))
)
)
teal_data <- teal.data::teal_data() |> within(iris <- head(iris)) |> within(mtcars <- mtcars)
datanames(teal_data) <- c("iris", "mtcars")
filtered_data <- teal_data_to_filtered_data(teal_data)

test_module1 <- module(
label = "iris tab",