Skip to content

Commit ddc57c7

Browse files
committed
download the thing once hopefully
1 parent 590baf3 commit ddc57c7

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

tests/testthat.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ if (stepcount::have_stepcount_condaenv()) {
1515
stepcount::use_stepcount_condaenv()
1616
}
1717

18+
1819
testthat::test_check("stepcount")

tests/testthat/test-stepcount.R

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@ remove_file_info = function(result) {
22
result$info$Filename = result$info$`Filesize(MB)` = NULL
33
result
44
}
5+
6+
ssl_model_path = file.path(
7+
tempdir(),
8+
stepcount::sc_model_filename(model_type = "ssl"))
9+
stepcount::sc_download_model(
10+
model_type = "ssl",
11+
model_path = ssl_model_path
12+
)
13+
14+
rf_model_path = file.path(
15+
tempdir(),
16+
stepcount::sc_model_filename(model_type = "rf"))
17+
stepcount::sc_download_model(
18+
model_type = "rf",
19+
model_path = rf_model_path
20+
)
21+
522
testthat::test_that("stepcount ssl works", {
623
file = system.file("extdata/P30_wrist100.csv.gz", package = "stepcount")
724
testthat::skip_if_not(stepcount_check())
825
if (stepcount_check()) {
926
model_type = "ssl"
10-
model_path = sc_model_filename(model_type = model_type)
11-
model_path = file.path(tempdir(), model_path)
12-
stepcount::sc_download_model(model_path = model_path, model_type = model_type)
13-
res = stepcount(file = file, model_type = model_type, model_path = model_path)
27+
res = stepcount(file = file, model_type = model_type, model_path = ssl_model_path)
1428
res = remove_file_info(res)
1529
testthat::expect_true(is.list(res))
1630
testthat::expect_true(all(c("steps", "walking") %in% names(res)))
1731
testthat::expect_named(res$steps, c("time", "steps"))
1832
testthat::expect_named(res$walking, c("time", "walking"))
1933

20-
model = sc_load_model(model_type = model_type, model_path = model_path,
34+
model = sc_load_model(model_type = model_type, model_path = ssl_model_path,
2135
as_python = TRUE)
2236
res_model = stepcount_with_model(file = file, model_type = model_type,
2337
model = model)
@@ -42,18 +56,16 @@ testthat::test_that("stepcount rf works", {
4256
testthat::skip_if_not(stepcount_check())
4357
if (stepcount_check()) {
4458
model_type = "rf"
45-
model_path = sc_model_filename(model_type = model_type)
46-
model_path = file.path(tempdir(), model_path)
47-
stepcount::sc_download_model(model_path = model_path, model_type = model_type)
48-
res = stepcount(file = file, model_type = model_type, model_path = model_path)
59+
stepcount::sc_download_model(model_path = rf_model_path, model_type = model_type)
60+
res = stepcount(file = file, model_type = model_type, model_path = rf_model_path)
4961
res = remove_file_info(res)
5062

5163
testthat::expect_true(is.list(res))
5264
testthat::expect_true(all(c("steps", "walking") %in% names(res)))
5365
testthat::expect_named(res$steps, c("time", "steps"))
5466
testthat::expect_named(res$walking, c("time", "walking"))
5567

56-
model = sc_load_model(model_type = model_type, model_path = model_path,
68+
model = sc_load_model(model_type = model_type, model_path = rf_model_path,
5769
as_python = TRUE)
5870
res_model = stepcount_with_model(file = file, model_type = model_type,
5971
model = model)

0 commit comments

Comments
 (0)