Skip to content

Commit 07aabbd

Browse files
committed
refactor: filter and move library calls to testthat.R
1 parent c6bc891 commit 07aabbd

File tree

8 files changed

+5
-19
lines changed

8 files changed

+5
-19
lines changed

tests/testthat.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
library(testthat)
22
library(epiprocess)
33

4+
library(dplyr)
5+
46
test_check("epiprocess")

tests/testthat/test-archive.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
library(dplyr)
2-
31
test_that("first input must be a data.frame", {
42
expect_error(as_epi_archive(c(1, 2, 3), compactify = FALSE),
53
regexp = "Must be of type 'data.frame'."

tests/testthat/test-autoplot.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
library(dplyr)
2-
31
d <- as.Date("2020-01-01")
4-
52
raw_df_chr <- dplyr::bind_rows(
63
dplyr::tibble(geo_value = "ak", time_value = d + 1:5, value = "a"),
74
dplyr::tibble(geo_value = "al", time_value = d + 1:5, value = "d")

tests/testthat/test-compactify.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
library(epiprocess)
2-
library(data.table)
3-
library(dplyr)
4-
51
dt <- archive_cases_dv_subset$DT
62
dt <- filter(dt, geo_value == "ca") %>%
73
filter(version <= "2020-06-15") %>%

tests/testthat/test-correlation.R

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
library(tibble)
2-
31
test_that("epi_cor throws an error for a non-epi_df for its first argument", {
42
expect_error(epi_cor(1:10, 1, 1))
53
expect_error(epi_cor(data.frame(x = 1:10), 1, 1))

tests/testthat/test-data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test_that("`archive_cases_dv_subset` is formed successfully", {
2-
expect_true(is_epi_archive(archive_cases_dv_subset))
2+
expect_class(archive_cases_dv_subset, "epi_archive")
33
})
44

55
test_that("`delayed_assign_with_unregister_awareness` works as expected on good promises", {

tests/testthat/test-epix_slide.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
library(dplyr)
2-
31
test_that("epix_slide only works on an epi_archive", {
42
expect_error(epix_slide(data.frame(x = 1)))
53
})
@@ -506,7 +504,7 @@ test_that("epix_as_of and epix_slide with long enough window are compatible", {
506504

507505
test_that("epix_slide `f` is passed an ungrouped `epi_archive` when `all_versions=TRUE`", {
508506
slide_fn <- function(x, gk, rtv) {
509-
expect_true(is_epi_archive(x))
507+
expect_class(x, "epi_archive")
510508
return(NA)
511509
}
512510

tests/testthat/test-methods-epi_archive.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
library(dplyr)
2-
31
ea <- archive_cases_dv_subset
4-
52
ea2_data <- tibble::tribble(
63
~geo_value, ~time_value, ~version, ~cases,
74
"ca", "2020-06-01", "2020-06-01", 1,
@@ -104,7 +101,7 @@ test_that("epix_truncate_version_after returns the same grouping type as input e
104101

105102
ea_as_of <- ea2 %>%
106103
epix_truncate_versions_after(max_version = as.Date("2020-06-04"))
107-
expect_true(is_epi_archive(ea_as_of, grouped_okay = FALSE))
104+
expect_class(ea_as_of, "epi_archive")
108105

109106
ea2_grouped <- ea2 %>% group_by(geo_value)
110107

0 commit comments

Comments
 (0)