Skip to content

Commit a83dfd7

Browse files
committed
add back the s3 test, but order cols correctly
1 parent e4664ef commit a83dfd7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tests/testthat/test-check_enough_train_data.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ test_that("check_enough_train_data outputs the correct recipe values", {
7474

7575
expect_equal(nrow(p), 2 * n)
7676
expect_equal(ncol(p), 4L)
77-
expect_named(p, c("time_value", "geo_value", "x", "y"))
77+
expect_s3_class(p, "epi_df")
78+
expect_named(p, c("geo_value", "time_value", "x", "y")) # order in epiprocess::new_epi_df
7879
expect_equal(
7980
p$time_value,
8081
rep(seq(as.Date("2020-01-01"), by = 1, length.out = n), times = 2)

tests/testthat/test-step_training_window.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ test_that("step_training_window works with default n_recent", {
1616

1717
expect_equal(nrow(p), 100L)
1818
expect_equal(ncol(p), 4L)
19-
20-
expect_named(p, c("time_value", "geo_value", "x", "y"))
19+
expect_s3_class(p, "epi_df")
20+
expect_named(p, c("geo_value", "time_value", "x", "y")) # order in epiprocess::new_epi_df
2121
expect_equal(
2222
p$time_value,
2323
rep(seq(as.Date("2020-02-20"), as.Date("2020-04-09"), by = 1), times = 2)
@@ -33,8 +33,8 @@ test_that("step_training_window works with specified n_recent", {
3333

3434
expect_equal(nrow(p2), 10L)
3535
expect_equal(ncol(p2), 4L)
36-
37-
expect_named(p2, c("time_value", "geo_value", "x", "y"))
36+
expect_s3_class(p2, "epi_df")
37+
expect_named(p2, c("geo_value", "time_value", "x", "y")) # order in epiprocess::new_epi_df
3838
expect_equal(
3939
p2$time_value,
4040
rep(seq(as.Date("2020-04-05"), as.Date("2020-04-09"), by = 1), times = 2)
@@ -53,9 +53,9 @@ test_that("step_training_window does not proceed with specified new_data", {
5353

5454
expect_equal(nrow(p3), 10L)
5555
expect_equal(ncol(p3), 4L)
56-
56+
expect_s3_class(p3, "epi_df")
5757
# cols will be predictors, outcomes, time_value, geo_value
58-
expect_named(p3, c("x", "y", "time_value", "geo_value"))
58+
expect_named(p3, c("geo_value", "time_value", "x", "y")) # order in epiprocess::new_epi_df
5959
expect_equal(
6060
p3$time_value,
6161
rep(seq(as.Date("2020-01-01"), as.Date("2020-01-10"), by = 1), times = 1)
@@ -83,8 +83,8 @@ test_that("step_training_window works with multiple keys", {
8383

8484
expect_equal(nrow(p4), 12L)
8585
expect_equal(ncol(p4), 5L)
86-
87-
expect_named(p4, c("time_value", "geo_value", "additional_key", "x", "y"))
86+
expect_s3_class(p4, "epi_df")
87+
expect_named(p4, c("geo_value", "time_value", "additional_key", "x", "y"))
8888
expect_equal(
8989
p4$time_value,
9090
rep(c(

0 commit comments

Comments
 (0)