Skip to content

Commit

Permalink
further constructor simplification simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Oct 25, 2023
1 parent cebb61f commit 4a0aeb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
2 changes: 0 additions & 2 deletions R/cdisc_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ cdisc_data <- function(...,
join_keys = teal.data::cdisc_join_keys(...),
code = "",
check = FALSE) {
data_objects <- list(...)
deprecated_join_keys_extract(data_objects, join_keys)
teal_data(..., join_keys = join_keys, code = code, check = check)
}

Expand Down
2 changes: 1 addition & 1 deletion R/teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ teal_data <- function(...,
Find more information on https://github.com/insightsengineering/teal/discussions/945'
)"
)
update_join_keys_to_primary(data_objects, join_keys)
deprecated_join_keys_extract(data_objects, join_keys)

x <- TealData$new(..., check = check, join_keys = join_keys)
if (length(code) > 0 && !identical(code, "")) {
Expand Down
43 changes: 21 additions & 22 deletions tests/testthat/test-teal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ testthat::test_that("teal_data sets passed join_keys to datasets correctly", {
jk <- join_keys(join_key("df1", "df2", "id"))
data <- teal_data(df1, df2, join_keys = jk, check = FALSE)

testthat::expect_equal(
data$get_join_keys(),
join_keys(
join_key("df1", "df2", "id"),
join_key("df1", "df1", "id"),
join_key("df2", "df2", "df2_id")
)
jk_expected <- join_keys(
join_key("df1", "df2", "id"),
join_key("df1", "df1", "id"),
join_key("df2", "df2", "df2_id")
)
jk_expected$set_parents(list(df1 = character(0), df2 = character(0)))

testthat::expect_equal(data$get_join_keys(), jk_expected)
})

testthat::test_that("teal_data sets passed JoinKeys to datasets correctly when key names differ", {
Expand All @@ -118,15 +118,15 @@ testthat::test_that("teal_data sets passed JoinKeys to datasets correctly when k
jk <- join_keys(join_key("df1", "df2", c(id = "fk")))
data <- teal_data(df1, df2, join_keys = jk, check = FALSE)

testthat::expect_equal(
data$get_join_keys(),
join_keys(
join_key("df1", "df2", c(id = "fk")),
join_key("df1", "df1", "id"),
join_key("df2", "df1", c(fk = "id")),
join_key("df2", "df2", "df2_id")
)
jk_expected <- join_keys(
join_key("df1", "df2", c(id = "fk")),
join_key("df1", "df1", "id"),
join_key("df2", "df1", c(fk = "id")),
join_key("df2", "df2", "df2_id")
)
jk_expected$set_parents(list(df1 = character(0), df2 = character(0)))

testthat::expect_equal(data$get_join_keys(), jk_expected)
})

testthat::test_that("teal_data sets passes JoinKeys to datasets correctly when key names differ (multiple keys)", {
Expand All @@ -137,14 +137,13 @@ testthat::test_that("teal_data sets passes JoinKeys to datasets correctly when k
data <- teal_data(df1, df2, check = FALSE)
data$mutate_join_keys("df1", "df2", c(id = "fk", id2 = "fk2"))

testthat::expect_equal(
data$get_join_keys(),
join_keys(
join_key("df1", "df1", "id"),
join_key("df2", "df2", "df2_id"),
join_key("df1", "df2", c(id = "fk", id2 = "fk2"))
)
jk_expected <- join_keys(
join_key("df1", "df1", "id"),
join_key("df2", "df2", "df2_id"),
join_key("df1", "df2", c(id = "fk", id2 = "fk2"))
)
jk_expected$set_parents(list(df1 = character(0), df2 = character(0)))
testthat::expect_equal(data$get_join_keys(), jk_expected)
})

testthat::test_that("teal_data returns TealData object with cdisc_dataset input", {
Expand Down

0 comments on commit 4a0aeb9

Please sign in to comment.