Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gladkia committed Dec 3, 2024
1 parent 36625c7 commit 031c349
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export(set_unique_cl_names_dt)
export(set_unique_drug_names)
export(set_unique_drug_names_dt)
export(set_unique_identifiers)
export(set_unique_names_dt)
export(shorten_normalization_type_name)
export(split_SE_components)
export(standardize_mae)
Expand Down
1 change: 1 addition & 0 deletions R/standardize_MAE.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ refine_rowdata <- function(rd, se, default_v = "Undefined") {
#' col_data <- S4Vectors::DataFrame(CellLineName = c("ID1", "ID1"), clid = c("C1", "C2"))
#' col_data <- set_unique_names_dt(col_data, primary_name = "CellLineName", secondary_name = "clid")
#' @keywords standardize_MAE
#' @export
#'
set_unique_names_dt <- function(dt, primary_name, secondary_name, sep = " ") {

Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-standardize_MAE.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ test_that("get_optional_rowdata_fields works as expected", {
expect_equal(opt_idfs2, idfs[["drug_moa"]])
})

test_that("set_unique_names works correctly", {
t_dframe <- S4Vectors::DataFrame(CellLineName = c("ID1", "ID1"),
clid = c("C1", "C2"))
t_dt <- data.table::data.table(CellLineName = c("ID1", "ID1"),
clid = c("C1", "C2"))
t_df <- data.frame(CellLineName = c("ID1", "ID1"),
clid = c("C1", "C2"))

u_dframe <- set_unique_names_dt(t_dframe,
primary_name = "CellLineName",
secondary_name = "clid")
u_dt <- set_unique_names_dt(t_dt, primary_name = "CellLineName", secondary_name = "clid")
u_df <- set_unique_names_dt(t_df, primary_name = "CellLineName", secondary_name = "clid")

expect_equal(data.table::as.data.table(u_df), u_dt)
expect_equal(data.table::as.data.table(u_dframe), u_dt)

expect_error(set_unique_names_dt(list()), "Must inherit from")
})


test_that("set_unique_cl_names_dt and set_unique_drug_names_dt works correctly", {

Expand Down

0 comments on commit 031c349

Please sign in to comment.