Skip to content
Merged
Changes from all commits
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
35 changes: 13 additions & 22 deletions tests/testthat/test_registration.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# There's currently an issue comparing tibbles so we do it col-by-col
test_by_col <- function(a, b) {
for (i in union(names(a), names(b))) {
expect_equal(a[[i]], b[[i]])
}
}

# ------------------------------------------------------------------------------

test_that('adding a new model', {
set_new_model("sponge")

Expand All @@ -21,7 +12,7 @@ test_that('adding a new model', {
tibble(engine = character(0), mode = character(0))
)

test_by_col(
expect_equal(
get_from_env("sponge_pkgs"),
tibble(engine = character(0), pkg = list(), mode = character(0))
)
Expand All @@ -30,19 +21,19 @@ expect_equal(
get_from_env("sponge_modes"), "unknown"
)

test_by_col(
expect_equal(
get_from_env("sponge_args"),
dplyr::tibble(engine = character(0), parsnip = character(0),
original = character(0), func = vector("list"),
has_submodel = logical(0))
)

test_by_col(
expect_equal(
get_from_env("sponge_fit"),
tibble(engine = character(0), mode = character(0), value = vector("list"))
)

test_by_col(
expect_equal(
get_from_env("sponge_predict"),
tibble(engine = character(0), mode = character(0),
type = character(0), value = vector("list"))
Expand Down Expand Up @@ -71,7 +62,7 @@ test_that('adding a new mode', {
test_that('adding a new engine', {
set_model_engine("sponge", mode = "classification", eng = "gum")

test_by_col(
expect_equal(
get_from_env("sponge"),
tibble(engine = "gum", mode = "classification")
)
Expand All @@ -96,20 +87,20 @@ test_that('adding a new package', {
expect_error(set_dependency("sponge", "gummies", "trident"))
expect_error(set_dependency("sponge", "gum", "trident", mode = "regression"))

test_by_col(
expect_equal(
get_from_env("sponge_pkgs"),
tibble(engine = "gum", pkg = list("trident"), mode = "classification")
)

set_dependency("sponge", "gum", "juicy-fruit", mode = "classification")
test_by_col(
expect_equal(
get_from_env("sponge_pkgs"),
tibble(engine = "gum",
pkg = list(c("trident", "juicy-fruit")),
mode = "classification")
)

test_by_col(
expect_equal(
get_dependency("sponge"),
tibble(engine = "gum",
pkg = list(c("trident", "juicy-fruit")),
Expand Down Expand Up @@ -142,7 +133,7 @@ test_that('adding a new argument', {
args <- get_from_env("sponge_args")
expect_equal(sum(args$parsnip == "modeling"), 1)

test_by_col(
expect_equal(
get_from_env("sponge_args"),
tibble(engine = "gum", parsnip = "modeling", original = "modelling",
func = list(list(pkg = "foo", fun = "bar")),
Expand Down Expand Up @@ -267,7 +258,7 @@ test_that('adding a new fit', {
)

fit_env_data <- get_from_env("sponge_fit")
test_by_col(
expect_equal(
fit_env_data[ 1:2],
tibble(engine = "gum", mode = "classification")
)
Expand Down Expand Up @@ -359,7 +350,7 @@ test_that('adding a new fit', {
)
)

test_by_col(
expect_equal(
get_fit("sponge")[, 1:2],
tibble(engine = "gum", mode = "classification")
)
Expand Down Expand Up @@ -391,7 +382,7 @@ test_that('adding a new predict method', {
)

pred_env_data <- get_from_env("sponge_predict")
test_by_col(
expect_equal(
pred_env_data[ 1:3],
tibble(engine = "gum", mode = "classification", type = "class")
)
Expand All @@ -401,7 +392,7 @@ test_that('adding a new predict method', {
class_vals
)

test_by_col(
expect_equal(
get_pred_type("sponge", "class")[ 1:3],
tibble(engine = "gum", mode = "classification", type = "class")
)
Expand Down